intrinsic.h (gfc_check_selected_real_kind, [...]): Update prototypes.
[gcc.git] / gcc / passes.c
1 /* Top level of GCC compilers (cc1, cc1plus, etc.)
2 Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
4 Free Software Foundation, Inc.
5
6 This file is part of GCC.
7
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
12
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
21
22 /* This is the top level of cc1/c++.
23 It parses command args, opens files, invokes the various passes
24 in the proper order, and counts the time used by each.
25 Error messages and low-level interface to malloc also handled here. */
26
27 #include "config.h"
28 #include "system.h"
29 #include "coretypes.h"
30 #include "tm.h"
31 #include <signal.h>
32
33 #ifdef HAVE_SYS_RESOURCE_H
34 # include <sys/resource.h>
35 #endif
36
37 #ifdef HAVE_SYS_TIMES_H
38 # include <sys/times.h>
39 #endif
40
41 #include "line-map.h"
42 #include "input.h"
43 #include "tree.h"
44 #include "rtl.h"
45 #include "tm_p.h"
46 #include "flags.h"
47 #include "insn-attr.h"
48 #include "insn-config.h"
49 #include "insn-flags.h"
50 #include "hard-reg-set.h"
51 #include "recog.h"
52 #include "output.h"
53 #include "except.h"
54 #include "function.h"
55 #include "toplev.h"
56 #include "expr.h"
57 #include "basic-block.h"
58 #include "intl.h"
59 #include "ggc.h"
60 #include "graph.h"
61 #include "regs.h"
62 #include "timevar.h"
63 #include "diagnostic-core.h"
64 #include "params.h"
65 #include "reload.h"
66 #include "dwarf2asm.h"
67 #include "integrate.h"
68 #include "debug.h"
69 #include "target.h"
70 #include "langhooks.h"
71 #include "cfglayout.h"
72 #include "cfgloop.h"
73 #include "hosthooks.h"
74 #include "cgraph.h"
75 #include "opts.h"
76 #include "coverage.h"
77 #include "value-prof.h"
78 #include "tree-inline.h"
79 #include "tree-flow.h"
80 #include "tree-pass.h"
81 #include "tree-dump.h"
82 #include "df.h"
83 #include "predict.h"
84 #include "lto-streamer.h"
85 #include "plugin.h"
86
87 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
88 #include "dwarf2out.h"
89 #endif
90
91 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
92 #include "dbxout.h"
93 #endif
94
95 #ifdef SDB_DEBUGGING_INFO
96 #include "sdbout.h"
97 #endif
98
99 #ifdef XCOFF_DEBUGGING_INFO
100 #include "xcoffout.h" /* Needed for external data
101 declarations for e.g. AIX 4.x. */
102 #endif
103
104 /* This is used for debugging. It allows the current pass to printed
105 from anywhere in compilation.
106 The variable current_pass is also used for statistics and plugins. */
107 struct opt_pass *current_pass;
108
109 /* Call from anywhere to find out what pass this is. Useful for
110 printing out debugging information deep inside an service
111 routine. */
112 void
113 print_current_pass (FILE *file)
114 {
115 if (current_pass)
116 fprintf (file, "current pass = %s (%d)\n",
117 current_pass->name, current_pass->static_pass_number);
118 else
119 fprintf (file, "no current pass.\n");
120 }
121
122
123 /* Call from the debugger to get the current pass name. */
124 DEBUG_FUNCTION void
125 debug_pass (void)
126 {
127 print_current_pass (stderr);
128 }
129
130
131
132 /* Global variables used to communicate with passes. */
133 int dump_flags;
134 bool in_gimple_form;
135 bool first_pass_instance;
136
137
138 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
139 and TYPE_DECL nodes.
140
141 This does nothing for local (non-static) variables, unless the
142 variable is a register variable with DECL_ASSEMBLER_NAME set. In
143 that case, or if the variable is not an automatic, it sets up the
144 RTL and outputs any assembler code (label definition, storage
145 allocation and initialization).
146
147 DECL is the declaration. TOP_LEVEL is nonzero
148 if this declaration is not within a function. */
149
150 void
151 rest_of_decl_compilation (tree decl,
152 int top_level,
153 int at_end)
154 {
155 /* We deferred calling assemble_alias so that we could collect
156 other attributes such as visibility. Emit the alias now. */
157 {
158 tree alias;
159 alias = lookup_attribute ("alias", DECL_ATTRIBUTES (decl));
160 if (alias)
161 {
162 alias = TREE_VALUE (TREE_VALUE (alias));
163 alias = get_identifier (TREE_STRING_POINTER (alias));
164 assemble_alias (decl, alias);
165 }
166 }
167
168 /* Can't defer this, because it needs to happen before any
169 later function definitions are processed. */
170 if (DECL_ASSEMBLER_NAME_SET_P (decl) && DECL_REGISTER (decl))
171 make_decl_rtl (decl);
172
173 /* Forward declarations for nested functions are not "external",
174 but we need to treat them as if they were. */
175 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
176 || TREE_CODE (decl) == FUNCTION_DECL)
177 {
178 timevar_push (TV_VARCONST);
179
180 /* Don't output anything when a tentative file-scope definition
181 is seen. But at end of compilation, do output code for them.
182
183 We do output all variables and rely on
184 callgraph code to defer them except for forward declarations
185 (see gcc.c-torture/compile/920624-1.c) */
186 if ((at_end
187 || !DECL_DEFER_OUTPUT (decl)
188 || DECL_INITIAL (decl))
189 && !DECL_EXTERNAL (decl))
190 {
191 /* When reading LTO unit, we also read varpool, so do not
192 rebuild it. */
193 if (in_lto_p && !at_end)
194 ;
195 else if (TREE_CODE (decl) != FUNCTION_DECL)
196 varpool_finalize_decl (decl);
197 else
198 assemble_variable (decl, top_level, at_end, 0);
199 }
200
201 #ifdef ASM_FINISH_DECLARE_OBJECT
202 if (decl == last_assemble_variable_decl)
203 {
204 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
205 top_level, at_end);
206 }
207 #endif
208
209 timevar_pop (TV_VARCONST);
210 }
211 else if (TREE_CODE (decl) == TYPE_DECL
212 /* Like in rest_of_type_compilation, avoid confusing the debug
213 information machinery when there are errors. */
214 && !seen_error ())
215 {
216 timevar_push (TV_SYMOUT);
217 debug_hooks->type_decl (decl, !top_level);
218 timevar_pop (TV_SYMOUT);
219 }
220
221 /* Let cgraph know about the existence of variables. */
222 if (in_lto_p && !at_end)
223 ;
224 else if (TREE_CODE (decl) == VAR_DECL && !DECL_EXTERNAL (decl))
225 varpool_node (decl);
226 }
227
228 /* Called after finishing a record, union or enumeral type. */
229
230 void
231 rest_of_type_compilation (tree type, int toplev)
232 {
233 /* Avoid confusing the debug information machinery when there are
234 errors. */
235 if (seen_error ())
236 return;
237
238 timevar_push (TV_SYMOUT);
239 debug_hooks->type_decl (TYPE_STUB_DECL (type), !toplev);
240 timevar_pop (TV_SYMOUT);
241 }
242
243 \f
244
245 void
246 finish_optimization_passes (void)
247 {
248 int i;
249 struct dump_file_info *dfi;
250 char *name;
251
252 timevar_push (TV_DUMP);
253 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
254 {
255 dump_file = dump_begin (pass_profile.pass.static_pass_number, NULL);
256 end_branch_prob ();
257 if (dump_file)
258 dump_end (pass_profile.pass.static_pass_number, dump_file);
259 }
260
261 if (optimize > 0)
262 {
263 dump_file = dump_begin (pass_combine.pass.static_pass_number, NULL);
264 if (dump_file)
265 {
266 dump_combine_total_stats (dump_file);
267 dump_end (pass_combine.pass.static_pass_number, dump_file);
268 }
269 }
270
271 /* Do whatever is necessary to finish printing the graphs. */
272 if (graph_dump_format != no_graph)
273 for (i = TDI_end; (dfi = get_dump_file_info (i)) != NULL; ++i)
274 if (dump_initialized_p (i)
275 && (dfi->flags & TDF_GRAPH) != 0
276 && (name = get_dump_file_name (i)) != NULL)
277 {
278 finish_graph_dump_file (name);
279 free (name);
280 }
281
282 timevar_pop (TV_DUMP);
283 }
284
285 static bool
286 gate_rest_of_compilation (void)
287 {
288 /* Early return if there were errors. We can run afoul of our
289 consistency checks, and there's not really much point in fixing them. */
290 return !(rtl_dump_and_exit || flag_syntax_only || seen_error ());
291 }
292
293 struct gimple_opt_pass pass_rest_of_compilation =
294 {
295 {
296 GIMPLE_PASS,
297 "*rest_of_compilation", /* name */
298 gate_rest_of_compilation, /* gate */
299 NULL, /* execute */
300 NULL, /* sub */
301 NULL, /* next */
302 0, /* static_pass_number */
303 TV_REST_OF_COMPILATION, /* tv_id */
304 PROP_rtl, /* properties_required */
305 0, /* properties_provided */
306 0, /* properties_destroyed */
307 0, /* todo_flags_start */
308 TODO_ggc_collect /* todo_flags_finish */
309 }
310 };
311
312 static bool
313 gate_postreload (void)
314 {
315 return reload_completed;
316 }
317
318 struct rtl_opt_pass pass_postreload =
319 {
320 {
321 RTL_PASS,
322 "*all-postreload", /* name */
323 gate_postreload, /* gate */
324 NULL, /* execute */
325 NULL, /* sub */
326 NULL, /* next */
327 0, /* static_pass_number */
328 TV_NONE, /* tv_id */
329 PROP_rtl, /* properties_required */
330 0, /* properties_provided */
331 0, /* properties_destroyed */
332 0, /* todo_flags_start */
333 TODO_ggc_collect | TODO_verify_rtl_sharing /* todo_flags_finish */
334 }
335 };
336
337
338
339 /* The root of the compilation pass tree, once constructed. */
340 struct opt_pass *all_passes, *all_small_ipa_passes, *all_lowering_passes,
341 *all_regular_ipa_passes, *all_lto_gen_passes;
342
343 /* This is used by plugins, and should also be used in register_pass. */
344 #define DEF_PASS_LIST(LIST) &LIST,
345 struct opt_pass **gcc_pass_lists[] = { GCC_PASS_LISTS NULL };
346 #undef DEF_PASS_LIST
347
348 /* A map from static pass id to optimization pass. */
349 struct opt_pass **passes_by_id;
350 int passes_by_id_size;
351
352 /* Set the static pass number of pass PASS to ID and record that
353 in the mapping from static pass number to pass. */
354
355 static void
356 set_pass_for_id (int id, struct opt_pass *pass)
357 {
358 pass->static_pass_number = id;
359 if (passes_by_id_size <= id)
360 {
361 passes_by_id = XRESIZEVEC (struct opt_pass *, passes_by_id, id + 1);
362 memset (passes_by_id + passes_by_id_size, 0,
363 (id + 1 - passes_by_id_size) * sizeof (void *));
364 passes_by_id_size = id + 1;
365 }
366 passes_by_id[id] = pass;
367 }
368
369 /* Return the pass with the static pass number ID. */
370
371 struct opt_pass *
372 get_pass_for_id (int id)
373 {
374 if (id >= passes_by_id_size)
375 return NULL;
376 return passes_by_id[id];
377 }
378
379 /* Iterate over the pass tree allocating dump file numbers. We want
380 to do this depth first, and independent of whether the pass is
381 enabled or not. */
382
383 void
384 register_one_dump_file (struct opt_pass *pass)
385 {
386 char *dot_name, *flag_name, *glob_name;
387 const char *name, *prefix;
388 char num[10];
389 int flags, id;
390
391 /* See below in next_pass_1. */
392 num[0] = '\0';
393 if (pass->static_pass_number != -1)
394 sprintf (num, "%d", ((int) pass->static_pass_number < 0
395 ? 1 : pass->static_pass_number));
396
397 /* The name is both used to identify the pass for the purposes of plugins,
398 and to specify dump file name and option.
399 The latter two might want something short which is not quite unique; for
400 that reason, we may have a disambiguating prefix, followed by a space
401 to mark the start of the following dump file name / option string. */
402 name = strchr (pass->name, ' ');
403 name = name ? name + 1 : pass->name;
404 dot_name = concat (".", name, num, NULL);
405 if (pass->type == SIMPLE_IPA_PASS || pass->type == IPA_PASS)
406 prefix = "ipa-", flags = TDF_IPA;
407 else if (pass->type == GIMPLE_PASS)
408 prefix = "tree-", flags = TDF_TREE;
409 else
410 prefix = "rtl-", flags = TDF_RTL;
411
412 flag_name = concat (prefix, name, num, NULL);
413 glob_name = concat (prefix, name, NULL);
414 id = dump_register (dot_name, flag_name, glob_name, flags);
415 set_pass_for_id (id, pass);
416 }
417
418 /* Recursive worker function for register_dump_files. */
419
420 static int
421 register_dump_files_1 (struct opt_pass *pass, int properties)
422 {
423 do
424 {
425 int new_properties = (properties | pass->properties_provided)
426 & ~pass->properties_destroyed;
427
428 if (pass->name && pass->name[0] != '*')
429 register_one_dump_file (pass);
430
431 if (pass->sub)
432 new_properties = register_dump_files_1 (pass->sub, new_properties);
433
434 /* If we have a gate, combine the properties that we could have with
435 and without the pass being examined. */
436 if (pass->gate)
437 properties &= new_properties;
438 else
439 properties = new_properties;
440
441 pass = pass->next;
442 }
443 while (pass);
444
445 return properties;
446 }
447
448 /* Register the dump files for the pipeline starting at PASS.
449 PROPERTIES reflects the properties that are guaranteed to be available at
450 the beginning of the pipeline. */
451
452 static void
453 register_dump_files (struct opt_pass *pass,int properties)
454 {
455 pass->properties_required |= properties;
456 register_dump_files_1 (pass, properties);
457 }
458
459 /* Look at the static_pass_number and duplicate the pass
460 if it is already added to a list. */
461
462 static struct opt_pass *
463 make_pass_instance (struct opt_pass *pass, bool track_duplicates)
464 {
465 /* A nonzero static_pass_number indicates that the
466 pass is already in the list. */
467 if (pass->static_pass_number)
468 {
469 struct opt_pass *new_pass;
470
471 if (pass->type == GIMPLE_PASS
472 || pass->type == RTL_PASS
473 || pass->type == SIMPLE_IPA_PASS)
474 {
475 new_pass = XNEW (struct opt_pass);
476 memcpy (new_pass, pass, sizeof (struct opt_pass));
477 }
478 else if (pass->type == IPA_PASS)
479 {
480 new_pass = (struct opt_pass *)XNEW (struct ipa_opt_pass_d);
481 memcpy (new_pass, pass, sizeof (struct ipa_opt_pass_d));
482 }
483 else
484 gcc_unreachable ();
485
486 new_pass->next = NULL;
487
488 new_pass->todo_flags_start &= ~TODO_mark_first_instance;
489
490 /* Indicate to register_dump_files that this pass has duplicates,
491 and so it should rename the dump file. The first instance will
492 be -1, and be number of duplicates = -static_pass_number - 1.
493 Subsequent instances will be > 0 and just the duplicate number. */
494 if ((pass->name && pass->name[0] != '*') || track_duplicates)
495 {
496 pass->static_pass_number -= 1;
497 new_pass->static_pass_number = -pass->static_pass_number;
498 }
499 return new_pass;
500 }
501 else
502 {
503 pass->todo_flags_start |= TODO_mark_first_instance;
504 pass->static_pass_number = -1;
505
506 invoke_plugin_callbacks (PLUGIN_NEW_PASS, pass);
507 }
508 return pass;
509 }
510
511 /* Add a pass to the pass list. Duplicate the pass if it's already
512 in the list. */
513
514 static struct opt_pass **
515 next_pass_1 (struct opt_pass **list, struct opt_pass *pass)
516 {
517 /* Every pass should have a name so that plugins can refer to them. */
518 gcc_assert (pass->name != NULL);
519
520 *list = make_pass_instance (pass, false);
521
522 return &(*list)->next;
523 }
524
525 /* List node for an inserted pass instance. We need to keep track of all
526 the newly-added pass instances (with 'added_pass_nodes' defined below)
527 so that we can register their dump files after pass-positioning is finished.
528 Registering dumping files needs to be post-processed or the
529 static_pass_number of the opt_pass object would be modified and mess up
530 the dump file names of future pass instances to be added. */
531
532 struct pass_list_node
533 {
534 struct opt_pass *pass;
535 struct pass_list_node *next;
536 };
537
538 static struct pass_list_node *added_pass_nodes = NULL;
539 static struct pass_list_node *prev_added_pass_node;
540
541 /* Insert the pass at the proper position. Return true if the pass
542 is successfully added.
543
544 NEW_PASS_INFO - new pass to be inserted
545 PASS_LIST - root of the pass list to insert the new pass to */
546
547 static bool
548 position_pass (struct register_pass_info *new_pass_info,
549 struct opt_pass **pass_list)
550 {
551 struct opt_pass *pass = *pass_list, *prev_pass = NULL;
552 bool success = false;
553
554 for ( ; pass; prev_pass = pass, pass = pass->next)
555 {
556 /* Check if the current pass is of the same type as the new pass and
557 matches the name and the instance number of the reference pass. */
558 if (pass->type == new_pass_info->pass->type
559 && pass->name
560 && !strcmp (pass->name, new_pass_info->reference_pass_name)
561 && ((new_pass_info->ref_pass_instance_number == 0)
562 || (new_pass_info->ref_pass_instance_number ==
563 pass->static_pass_number)
564 || (new_pass_info->ref_pass_instance_number == 1
565 && pass->todo_flags_start & TODO_mark_first_instance)))
566 {
567 struct opt_pass *new_pass;
568 struct pass_list_node *new_pass_node;
569
570 new_pass = make_pass_instance (new_pass_info->pass, true);
571
572 /* Insert the new pass instance based on the positioning op. */
573 switch (new_pass_info->pos_op)
574 {
575 case PASS_POS_INSERT_AFTER:
576 new_pass->next = pass->next;
577 pass->next = new_pass;
578
579 /* Skip newly inserted pass to avoid repeated
580 insertions in the case where the new pass and the
581 existing one have the same name. */
582 pass = new_pass;
583 break;
584 case PASS_POS_INSERT_BEFORE:
585 new_pass->next = pass;
586 if (prev_pass)
587 prev_pass->next = new_pass;
588 else
589 *pass_list = new_pass;
590 break;
591 case PASS_POS_REPLACE:
592 new_pass->next = pass->next;
593 if (prev_pass)
594 prev_pass->next = new_pass;
595 else
596 *pass_list = new_pass;
597 new_pass->sub = pass->sub;
598 new_pass->tv_id = pass->tv_id;
599 pass = new_pass;
600 break;
601 default:
602 error ("Invalid pass positioning operation");
603 return false;
604 }
605
606 /* Save the newly added pass (instance) in the added_pass_nodes
607 list so that we can register its dump file later. Note that
608 we cannot register the dump file now because doing so will modify
609 the static_pass_number of the opt_pass object and therefore
610 mess up the dump file name of future instances. */
611 new_pass_node = XCNEW (struct pass_list_node);
612 new_pass_node->pass = new_pass;
613 if (!added_pass_nodes)
614 added_pass_nodes = new_pass_node;
615 else
616 prev_added_pass_node->next = new_pass_node;
617 prev_added_pass_node = new_pass_node;
618
619 success = true;
620 }
621
622 if (pass->sub && position_pass (new_pass_info, &pass->sub))
623 success = true;
624 }
625
626 return success;
627 }
628
629 /* Hooks a new pass into the pass lists.
630
631 PASS_INFO - pass information that specifies the opt_pass object,
632 reference pass, instance number, and how to position
633 the pass */
634
635 void
636 register_pass (struct register_pass_info *pass_info)
637 {
638 bool all_instances, success;
639
640 /* The checks below could fail in buggy plugins. Existing GCC
641 passes should never fail these checks, so we mention plugin in
642 the messages. */
643 if (!pass_info->pass)
644 fatal_error ("plugin cannot register a missing pass");
645
646 if (!pass_info->pass->name)
647 fatal_error ("plugin cannot register an unnamed pass");
648
649 if (!pass_info->reference_pass_name)
650 fatal_error
651 ("plugin cannot register pass %qs without reference pass name",
652 pass_info->pass->name);
653
654 /* Try to insert the new pass to the pass lists. We need to check
655 all five lists as the reference pass could be in one (or all) of
656 them. */
657 all_instances = pass_info->ref_pass_instance_number == 0;
658 success = position_pass (pass_info, &all_lowering_passes);
659 if (!success || all_instances)
660 success |= position_pass (pass_info, &all_small_ipa_passes);
661 if (!success || all_instances)
662 success |= position_pass (pass_info, &all_regular_ipa_passes);
663 if (!success || all_instances)
664 success |= position_pass (pass_info, &all_lto_gen_passes);
665 if (!success || all_instances)
666 success |= position_pass (pass_info, &all_passes);
667 if (!success)
668 fatal_error
669 ("pass %qs not found but is referenced by new pass %qs",
670 pass_info->reference_pass_name, pass_info->pass->name);
671
672 /* OK, we have successfully inserted the new pass. We need to register
673 the dump files for the newly added pass and its duplicates (if any).
674 Because the registration of plugin/backend passes happens after the
675 command-line options are parsed, the options that specify single
676 pass dumping (e.g. -fdump-tree-PASSNAME) cannot be used for new
677 passes. Therefore we currently can only enable dumping of
678 new passes when the 'dump-all' flags (e.g. -fdump-tree-all)
679 are specified. While doing so, we also delete the pass_list_node
680 objects created during pass positioning. */
681 while (added_pass_nodes)
682 {
683 struct pass_list_node *next_node = added_pass_nodes->next;
684 enum tree_dump_index tdi;
685 register_one_dump_file (added_pass_nodes->pass);
686 if (added_pass_nodes->pass->type == SIMPLE_IPA_PASS
687 || added_pass_nodes->pass->type == IPA_PASS)
688 tdi = TDI_ipa_all;
689 else if (added_pass_nodes->pass->type == GIMPLE_PASS)
690 tdi = TDI_tree_all;
691 else
692 tdi = TDI_rtl_all;
693 /* Check if dump-all flag is specified. */
694 if (get_dump_file_info (tdi)->state)
695 get_dump_file_info (added_pass_nodes->pass->static_pass_number)
696 ->state = get_dump_file_info (tdi)->state;
697 XDELETE (added_pass_nodes);
698 added_pass_nodes = next_node;
699 }
700 }
701
702 /* Construct the pass tree. The sequencing of passes is driven by
703 the cgraph routines:
704
705 cgraph_finalize_compilation_unit ()
706 for each node N in the cgraph
707 cgraph_analyze_function (N)
708 cgraph_lower_function (N) -> all_lowering_passes
709
710 If we are optimizing, cgraph_optimize is then invoked:
711
712 cgraph_optimize ()
713 ipa_passes () -> all_small_ipa_passes
714 cgraph_expand_all_functions ()
715 for each node N in the cgraph
716 cgraph_expand_function (N)
717 tree_rest_of_compilation (DECL (N)) -> all_passes
718 */
719
720 void
721 init_optimization_passes (void)
722 {
723 struct opt_pass **p;
724
725 #define NEXT_PASS(PASS) (p = next_pass_1 (p, &((PASS).pass)))
726
727 /* All passes needed to lower the function into shape optimizers can
728 operate on. These passes are always run first on the function, but
729 backend might produce already lowered functions that are not processed
730 by these passes. */
731 p = &all_lowering_passes;
732 NEXT_PASS (pass_warn_unused_result);
733 NEXT_PASS (pass_diagnose_omp_blocks);
734 NEXT_PASS (pass_mudflap_1);
735 NEXT_PASS (pass_lower_omp);
736 NEXT_PASS (pass_lower_cf);
737 NEXT_PASS (pass_refactor_eh);
738 NEXT_PASS (pass_lower_eh);
739 NEXT_PASS (pass_build_cfg);
740 NEXT_PASS (pass_lower_vector);
741 NEXT_PASS (pass_warn_function_return);
742 NEXT_PASS (pass_build_cgraph_edges);
743 NEXT_PASS (pass_inline_parameters);
744 *p = NULL;
745
746 /* Interprocedural optimization passes. */
747 p = &all_small_ipa_passes;
748 NEXT_PASS (pass_ipa_free_lang_data);
749 NEXT_PASS (pass_ipa_function_and_variable_visibility);
750 NEXT_PASS (pass_ipa_early_inline);
751 {
752 struct opt_pass **p = &pass_ipa_early_inline.pass.sub;
753 NEXT_PASS (pass_early_inline);
754 NEXT_PASS (pass_inline_parameters);
755 NEXT_PASS (pass_rebuild_cgraph_edges);
756 }
757 NEXT_PASS (pass_early_local_passes);
758 {
759 struct opt_pass **p = &pass_early_local_passes.pass.sub;
760 NEXT_PASS (pass_fixup_cfg);
761 NEXT_PASS (pass_tree_profile);
762 NEXT_PASS (pass_cleanup_cfg);
763 NEXT_PASS (pass_init_datastructures);
764 NEXT_PASS (pass_expand_omp);
765
766 NEXT_PASS (pass_referenced_vars);
767 NEXT_PASS (pass_build_ssa);
768 NEXT_PASS (pass_early_warn_uninitialized);
769 /* Note that it is not strictly necessary to schedule an early
770 inline pass here. However, some test cases (e.g.,
771 g++.dg/other/p334435.C g++.dg/other/i386-1.C) expect extern
772 inline functions to be inlined even at -O0. This does not
773 happen during the first early inline pass. */
774 NEXT_PASS (pass_rebuild_cgraph_edges);
775 NEXT_PASS (pass_early_inline);
776 NEXT_PASS (pass_all_early_optimizations);
777 {
778 struct opt_pass **p = &pass_all_early_optimizations.pass.sub;
779 NEXT_PASS (pass_remove_cgraph_callee_edges);
780 NEXT_PASS (pass_rename_ssa_copies);
781 NEXT_PASS (pass_ccp);
782 NEXT_PASS (pass_forwprop);
783 /* pass_build_ealias is a dummy pass that ensures that we
784 execute TODO_rebuild_alias at this point. Re-building
785 alias information also rewrites no longer addressed
786 locals into SSA form if possible. */
787 NEXT_PASS (pass_build_ealias);
788 NEXT_PASS (pass_sra_early);
789 NEXT_PASS (pass_copy_prop);
790 NEXT_PASS (pass_merge_phi);
791 NEXT_PASS (pass_cd_dce);
792 NEXT_PASS (pass_early_ipa_sra);
793 NEXT_PASS (pass_tail_recursion);
794 NEXT_PASS (pass_convert_switch);
795 NEXT_PASS (pass_cleanup_eh);
796 NEXT_PASS (pass_profile);
797 NEXT_PASS (pass_local_pure_const);
798 /* Split functions creates parts that are not run through
799 early optimizations again. It is thus good idea to do this
800 late. */
801 NEXT_PASS (pass_split_functions);
802 }
803 NEXT_PASS (pass_release_ssa_names);
804 NEXT_PASS (pass_rebuild_cgraph_edges);
805 NEXT_PASS (pass_inline_parameters);
806 }
807 NEXT_PASS (pass_ipa_increase_alignment);
808 NEXT_PASS (pass_ipa_matrix_reorg);
809 *p = NULL;
810
811 p = &all_regular_ipa_passes;
812 NEXT_PASS (pass_ipa_whole_program_visibility);
813 NEXT_PASS (pass_ipa_profile);
814 NEXT_PASS (pass_ipa_cp);
815 NEXT_PASS (pass_ipa_inline);
816 NEXT_PASS (pass_ipa_pure_const);
817 NEXT_PASS (pass_ipa_reference);
818 NEXT_PASS (pass_ipa_type_escape);
819 NEXT_PASS (pass_ipa_pta);
820 NEXT_PASS (pass_ipa_struct_reorg);
821 *p = NULL;
822
823 p = &all_lto_gen_passes;
824 NEXT_PASS (pass_ipa_lto_gimple_out);
825 NEXT_PASS (pass_ipa_lto_finish_out); /* This must be the last LTO pass. */
826 *p = NULL;
827
828 /* These passes are run after IPA passes on every function that is being
829 output to the assembler file. */
830 p = &all_passes;
831 NEXT_PASS (pass_lower_eh_dispatch);
832 NEXT_PASS (pass_all_optimizations);
833 {
834 struct opt_pass **p = &pass_all_optimizations.pass.sub;
835 NEXT_PASS (pass_remove_cgraph_callee_edges);
836 /* Initial scalar cleanups before alias computation.
837 They ensure memory accesses are not indirect wherever possible. */
838 NEXT_PASS (pass_strip_predict_hints);
839 NEXT_PASS (pass_update_address_taken);
840 NEXT_PASS (pass_rename_ssa_copies);
841 NEXT_PASS (pass_complete_unrolli);
842 NEXT_PASS (pass_ccp);
843 NEXT_PASS (pass_forwprop);
844 NEXT_PASS (pass_call_cdce);
845 /* pass_build_alias is a dummy pass that ensures that we
846 execute TODO_rebuild_alias at this point. Re-building
847 alias information also rewrites no longer addressed
848 locals into SSA form if possible. */
849 NEXT_PASS (pass_build_alias);
850 NEXT_PASS (pass_return_slot);
851 NEXT_PASS (pass_phiprop);
852 NEXT_PASS (pass_fre);
853 NEXT_PASS (pass_copy_prop);
854 NEXT_PASS (pass_merge_phi);
855 NEXT_PASS (pass_vrp);
856 NEXT_PASS (pass_dce);
857 NEXT_PASS (pass_cselim);
858 NEXT_PASS (pass_tree_ifcombine);
859 NEXT_PASS (pass_phiopt);
860 NEXT_PASS (pass_tail_recursion);
861 NEXT_PASS (pass_ch);
862 NEXT_PASS (pass_stdarg);
863 NEXT_PASS (pass_lower_complex);
864 NEXT_PASS (pass_sra);
865 NEXT_PASS (pass_rename_ssa_copies);
866 /* The dom pass will also resolve all __builtin_constant_p calls
867 that are still there to 0. This has to be done after some
868 propagations have already run, but before some more dead code
869 is removed, and this place fits nicely. Remember this when
870 trying to move or duplicate pass_dominator somewhere earlier. */
871 NEXT_PASS (pass_dominator);
872 /* The only const/copy propagation opportunities left after
873 DOM should be due to degenerate PHI nodes. So rather than
874 run the full propagators, run a specialized pass which
875 only examines PHIs to discover const/copy propagation
876 opportunities. */
877 NEXT_PASS (pass_phi_only_cprop);
878 NEXT_PASS (pass_dse);
879 NEXT_PASS (pass_reassoc);
880 NEXT_PASS (pass_dce);
881 NEXT_PASS (pass_forwprop);
882 NEXT_PASS (pass_phiopt);
883 NEXT_PASS (pass_object_sizes);
884 NEXT_PASS (pass_ccp);
885 NEXT_PASS (pass_copy_prop);
886 NEXT_PASS (pass_cse_sincos);
887 NEXT_PASS (pass_optimize_bswap);
888 NEXT_PASS (pass_split_crit_edges);
889 NEXT_PASS (pass_pre);
890 NEXT_PASS (pass_sink_code);
891 NEXT_PASS (pass_tree_loop);
892 {
893 struct opt_pass **p = &pass_tree_loop.pass.sub;
894 NEXT_PASS (pass_tree_loop_init);
895 NEXT_PASS (pass_lim);
896 NEXT_PASS (pass_copy_prop);
897 NEXT_PASS (pass_dce_loop);
898 NEXT_PASS (pass_tree_unswitch);
899 NEXT_PASS (pass_scev_cprop);
900 NEXT_PASS (pass_record_bounds);
901 NEXT_PASS (pass_check_data_deps);
902 NEXT_PASS (pass_loop_distribution);
903 NEXT_PASS (pass_linear_transform);
904 NEXT_PASS (pass_graphite_transforms);
905 {
906 struct opt_pass **p = &pass_graphite_transforms.pass.sub;
907 NEXT_PASS (pass_copy_prop);
908 NEXT_PASS (pass_dce_loop);
909 NEXT_PASS (pass_lim);
910 }
911 NEXT_PASS (pass_iv_canon);
912 NEXT_PASS (pass_if_conversion);
913 NEXT_PASS (pass_vectorize);
914 {
915 struct opt_pass **p = &pass_vectorize.pass.sub;
916 NEXT_PASS (pass_lower_vector_ssa);
917 NEXT_PASS (pass_dce_loop);
918 }
919 NEXT_PASS (pass_predcom);
920 NEXT_PASS (pass_complete_unroll);
921 NEXT_PASS (pass_slp_vectorize);
922 NEXT_PASS (pass_parallelize_loops);
923 NEXT_PASS (pass_loop_prefetch);
924 NEXT_PASS (pass_iv_optimize);
925 NEXT_PASS (pass_tree_loop_done);
926 }
927 NEXT_PASS (pass_cse_reciprocals);
928 NEXT_PASS (pass_reassoc);
929 NEXT_PASS (pass_vrp);
930 NEXT_PASS (pass_dominator);
931 /* The only const/copy propagation opportunities left after
932 DOM should be due to degenerate PHI nodes. So rather than
933 run the full propagators, run a specialized pass which
934 only examines PHIs to discover const/copy propagation
935 opportunities. */
936 NEXT_PASS (pass_phi_only_cprop);
937 NEXT_PASS (pass_cd_dce);
938 NEXT_PASS (pass_tracer);
939
940 /* FIXME: If DCE is not run before checking for uninitialized uses,
941 we may get false warnings (e.g., testsuite/gcc.dg/uninit-5.c).
942 However, this also causes us to misdiagnose cases that should be
943 real warnings (e.g., testsuite/gcc.dg/pr18501.c).
944
945 To fix the false positives in uninit-5.c, we would have to
946 account for the predicates protecting the set and the use of each
947 variable. Using a representation like Gated Single Assignment
948 may help. */
949 NEXT_PASS (pass_late_warn_uninitialized);
950 NEXT_PASS (pass_dse);
951 NEXT_PASS (pass_forwprop);
952 NEXT_PASS (pass_phiopt);
953 NEXT_PASS (pass_fold_builtins);
954 NEXT_PASS (pass_optimize_widening_mul);
955 NEXT_PASS (pass_tail_calls);
956 NEXT_PASS (pass_rename_ssa_copies);
957 NEXT_PASS (pass_uncprop);
958 NEXT_PASS (pass_local_pure_const);
959 }
960 NEXT_PASS (pass_lower_complex_O0);
961 NEXT_PASS (pass_cleanup_eh);
962 NEXT_PASS (pass_lower_resx);
963 NEXT_PASS (pass_nrv);
964 NEXT_PASS (pass_mudflap_2);
965 NEXT_PASS (pass_cleanup_cfg_post_optimizing);
966 NEXT_PASS (pass_warn_function_noreturn);
967
968 NEXT_PASS (pass_expand);
969
970 NEXT_PASS (pass_rest_of_compilation);
971 {
972 struct opt_pass **p = &pass_rest_of_compilation.pass.sub;
973 NEXT_PASS (pass_init_function);
974 NEXT_PASS (pass_jump);
975 NEXT_PASS (pass_rtl_eh);
976 NEXT_PASS (pass_initial_value_sets);
977 NEXT_PASS (pass_unshare_all_rtl);
978 NEXT_PASS (pass_instantiate_virtual_regs);
979 NEXT_PASS (pass_into_cfg_layout_mode);
980 NEXT_PASS (pass_jump2);
981 NEXT_PASS (pass_lower_subreg);
982 NEXT_PASS (pass_df_initialize_opt);
983 NEXT_PASS (pass_cse);
984 NEXT_PASS (pass_rtl_fwprop);
985 NEXT_PASS (pass_rtl_cprop);
986 NEXT_PASS (pass_rtl_pre);
987 NEXT_PASS (pass_rtl_hoist);
988 NEXT_PASS (pass_rtl_cprop);
989 NEXT_PASS (pass_rtl_store_motion);
990 NEXT_PASS (pass_cse_after_global_opts);
991 NEXT_PASS (pass_rtl_ifcvt);
992 NEXT_PASS (pass_reginfo_init);
993 /* Perform loop optimizations. It might be better to do them a bit
994 sooner, but we want the profile feedback to work more
995 efficiently. */
996 NEXT_PASS (pass_loop2);
997 {
998 struct opt_pass **p = &pass_loop2.pass.sub;
999 NEXT_PASS (pass_rtl_loop_init);
1000 NEXT_PASS (pass_rtl_move_loop_invariants);
1001 NEXT_PASS (pass_rtl_unswitch);
1002 NEXT_PASS (pass_rtl_unroll_and_peel_loops);
1003 NEXT_PASS (pass_rtl_doloop);
1004 NEXT_PASS (pass_rtl_loop_done);
1005 *p = NULL;
1006 }
1007 NEXT_PASS (pass_web);
1008 NEXT_PASS (pass_rtl_cprop);
1009 NEXT_PASS (pass_cse2);
1010 NEXT_PASS (pass_rtl_dse1);
1011 NEXT_PASS (pass_rtl_fwprop_addr);
1012 NEXT_PASS (pass_inc_dec);
1013 NEXT_PASS (pass_initialize_regs);
1014 NEXT_PASS (pass_ud_rtl_dce);
1015 NEXT_PASS (pass_combine);
1016 NEXT_PASS (pass_if_after_combine);
1017 NEXT_PASS (pass_partition_blocks);
1018 NEXT_PASS (pass_regmove);
1019 NEXT_PASS (pass_outof_cfg_layout_mode);
1020 NEXT_PASS (pass_split_all_insns);
1021 NEXT_PASS (pass_lower_subreg2);
1022 NEXT_PASS (pass_df_initialize_no_opt);
1023 NEXT_PASS (pass_stack_ptr_mod);
1024 NEXT_PASS (pass_mode_switching);
1025 NEXT_PASS (pass_match_asm_constraints);
1026 NEXT_PASS (pass_sms);
1027 NEXT_PASS (pass_sched);
1028 NEXT_PASS (pass_ira);
1029 NEXT_PASS (pass_postreload);
1030 {
1031 struct opt_pass **p = &pass_postreload.pass.sub;
1032 NEXT_PASS (pass_postreload_cse);
1033 NEXT_PASS (pass_gcse2);
1034 NEXT_PASS (pass_split_after_reload);
1035 NEXT_PASS (pass_implicit_zee);
1036 NEXT_PASS (pass_branch_target_load_optimize1);
1037 NEXT_PASS (pass_thread_prologue_and_epilogue);
1038 NEXT_PASS (pass_rtl_dse2);
1039 NEXT_PASS (pass_stack_adjustments);
1040 NEXT_PASS (pass_peephole2);
1041 NEXT_PASS (pass_if_after_reload);
1042 NEXT_PASS (pass_regrename);
1043 NEXT_PASS (pass_cprop_hardreg);
1044 NEXT_PASS (pass_fast_rtl_dce);
1045 NEXT_PASS (pass_reorder_blocks);
1046 NEXT_PASS (pass_branch_target_load_optimize2);
1047 NEXT_PASS (pass_leaf_regs);
1048 NEXT_PASS (pass_split_before_sched2);
1049 NEXT_PASS (pass_sched2);
1050 NEXT_PASS (pass_stack_regs);
1051 {
1052 struct opt_pass **p = &pass_stack_regs.pass.sub;
1053 NEXT_PASS (pass_split_before_regstack);
1054 NEXT_PASS (pass_stack_regs_run);
1055 }
1056 NEXT_PASS (pass_compute_alignments);
1057 NEXT_PASS (pass_duplicate_computed_gotos);
1058 NEXT_PASS (pass_variable_tracking);
1059 NEXT_PASS (pass_free_cfg);
1060 NEXT_PASS (pass_machine_reorg);
1061 NEXT_PASS (pass_cleanup_barriers);
1062 NEXT_PASS (pass_delay_slots);
1063 NEXT_PASS (pass_split_for_shorten_branches);
1064 NEXT_PASS (pass_convert_to_eh_region_ranges);
1065 NEXT_PASS (pass_shorten_branches);
1066 NEXT_PASS (pass_set_nothrow_function_flags);
1067 NEXT_PASS (pass_final);
1068 }
1069 NEXT_PASS (pass_df_finish);
1070 }
1071 NEXT_PASS (pass_clean_state);
1072 *p = NULL;
1073
1074 #undef NEXT_PASS
1075
1076 /* Register the passes with the tree dump code. */
1077 register_dump_files (all_lowering_passes, PROP_gimple_any);
1078 register_dump_files (all_small_ipa_passes,
1079 PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh
1080 | PROP_cfg);
1081 register_dump_files (all_regular_ipa_passes,
1082 PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh
1083 | PROP_cfg);
1084 register_dump_files (all_lto_gen_passes,
1085 PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh
1086 | PROP_cfg);
1087 register_dump_files (all_passes,
1088 PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh
1089 | PROP_cfg);
1090 }
1091
1092 /* If we are in IPA mode (i.e., current_function_decl is NULL), call
1093 function CALLBACK for every function in the call graph. Otherwise,
1094 call CALLBACK on the current function. */
1095
1096 static void
1097 do_per_function (void (*callback) (void *data), void *data)
1098 {
1099 if (current_function_decl)
1100 callback (data);
1101 else
1102 {
1103 struct cgraph_node *node;
1104 for (node = cgraph_nodes; node; node = node->next)
1105 if (node->analyzed && gimple_has_body_p (node->decl)
1106 && (!node->clone_of || node->decl != node->clone_of->decl))
1107 {
1108 push_cfun (DECL_STRUCT_FUNCTION (node->decl));
1109 current_function_decl = node->decl;
1110 callback (data);
1111 if (!flag_wpa)
1112 {
1113 free_dominance_info (CDI_DOMINATORS);
1114 free_dominance_info (CDI_POST_DOMINATORS);
1115 }
1116 current_function_decl = NULL;
1117 pop_cfun ();
1118 ggc_collect ();
1119 }
1120 }
1121 }
1122
1123 /* Because inlining might remove no-longer reachable nodes, we need to
1124 keep the array visible to garbage collector to avoid reading collected
1125 out nodes. */
1126 static int nnodes;
1127 static GTY ((length ("nnodes"))) cgraph_node_ptr *order;
1128
1129 /* If we are in IPA mode (i.e., current_function_decl is NULL), call
1130 function CALLBACK for every function in the call graph. Otherwise,
1131 call CALLBACK on the current function.
1132 This function is global so that plugins can use it. */
1133 void
1134 do_per_function_toporder (void (*callback) (void *data), void *data)
1135 {
1136 int i;
1137
1138 if (current_function_decl)
1139 callback (data);
1140 else
1141 {
1142 gcc_assert (!order);
1143 order = ggc_alloc_vec_cgraph_node_ptr (cgraph_n_nodes);
1144 nnodes = cgraph_postorder (order);
1145 for (i = nnodes - 1; i >= 0; i--)
1146 order[i]->process = 1;
1147 for (i = nnodes - 1; i >= 0; i--)
1148 {
1149 struct cgraph_node *node = order[i];
1150
1151 /* Allow possibly removed nodes to be garbage collected. */
1152 order[i] = NULL;
1153 node->process = 0;
1154 if (node->analyzed)
1155 {
1156 push_cfun (DECL_STRUCT_FUNCTION (node->decl));
1157 current_function_decl = node->decl;
1158 callback (data);
1159 free_dominance_info (CDI_DOMINATORS);
1160 free_dominance_info (CDI_POST_DOMINATORS);
1161 current_function_decl = NULL;
1162 pop_cfun ();
1163 ggc_collect ();
1164 }
1165 }
1166 }
1167 ggc_free (order);
1168 order = NULL;
1169 nnodes = 0;
1170 }
1171
1172 /* Perform all TODO actions that ought to be done on each function. */
1173
1174 static void
1175 execute_function_todo (void *data)
1176 {
1177 unsigned int flags = (size_t)data;
1178 flags &= ~cfun->last_verified;
1179 if (!flags)
1180 return;
1181
1182 /* Always cleanup the CFG before trying to update SSA. */
1183 if (flags & TODO_cleanup_cfg)
1184 {
1185 bool cleanup = cleanup_tree_cfg ();
1186
1187 if (cleanup && (cfun->curr_properties & PROP_ssa))
1188 flags |= TODO_remove_unused_locals;
1189
1190 /* When cleanup_tree_cfg merges consecutive blocks, it may
1191 perform some simplistic propagation when removing single
1192 valued PHI nodes. This propagation may, in turn, cause the
1193 SSA form to become out-of-date (see PR 22037). So, even
1194 if the parent pass had not scheduled an SSA update, we may
1195 still need to do one. */
1196 if (!(flags & TODO_update_ssa_any) && need_ssa_update_p (cfun))
1197 flags |= TODO_update_ssa;
1198 }
1199
1200 if (flags & TODO_update_ssa_any)
1201 {
1202 unsigned update_flags = flags & TODO_update_ssa_any;
1203 update_ssa (update_flags);
1204 cfun->last_verified &= ~TODO_verify_ssa;
1205 }
1206
1207 if (flags & TODO_update_address_taken)
1208 execute_update_addresses_taken (true);
1209
1210 if (flags & TODO_rebuild_alias)
1211 {
1212 if (!(flags & TODO_update_address_taken))
1213 execute_update_addresses_taken (true);
1214 compute_may_aliases ();
1215 }
1216
1217 if (flags & TODO_remove_unused_locals)
1218 remove_unused_locals ();
1219
1220 if ((flags & TODO_dump_func) && dump_file && current_function_decl)
1221 {
1222 if (cfun->curr_properties & PROP_trees)
1223 dump_function_to_file (current_function_decl, dump_file, dump_flags);
1224 else
1225 {
1226 if (dump_flags & TDF_SLIM)
1227 print_rtl_slim_with_bb (dump_file, get_insns (), dump_flags);
1228 else if ((cfun->curr_properties & PROP_cfg)
1229 && (dump_flags & TDF_BLOCKS))
1230 print_rtl_with_bb (dump_file, get_insns ());
1231 else
1232 print_rtl (dump_file, get_insns ());
1233
1234 if ((cfun->curr_properties & PROP_cfg)
1235 && graph_dump_format != no_graph
1236 && (dump_flags & TDF_GRAPH))
1237 print_rtl_graph_with_bb (dump_file_name, get_insns ());
1238 }
1239
1240 /* Flush the file. If verification fails, we won't be able to
1241 close the file before aborting. */
1242 fflush (dump_file);
1243 }
1244
1245 if (flags & TODO_rebuild_frequencies)
1246 {
1247 if (profile_status == PROFILE_GUESSED)
1248 {
1249 loop_optimizer_init (0);
1250 add_noreturn_fake_exit_edges ();
1251 mark_irreducible_loops ();
1252 connect_infinite_loops_to_exit ();
1253 estimate_bb_frequencies ();
1254 remove_fake_exit_edges ();
1255 loop_optimizer_finalize ();
1256 }
1257 else if (profile_status == PROFILE_READ)
1258 counts_to_freqs ();
1259 else
1260 gcc_unreachable ();
1261 }
1262
1263 #if defined ENABLE_CHECKING
1264 if (flags & TODO_verify_ssa
1265 || (current_loops && loops_state_satisfies_p (LOOP_CLOSED_SSA)))
1266 verify_ssa (true);
1267 if (flags & TODO_verify_flow)
1268 verify_flow_info ();
1269 if (flags & TODO_verify_stmts)
1270 verify_stmts ();
1271 if (current_loops && loops_state_satisfies_p (LOOP_CLOSED_SSA))
1272 verify_loop_closed_ssa (false);
1273 if (flags & TODO_verify_rtl_sharing)
1274 verify_rtl_sharing ();
1275 #endif
1276
1277 cfun->last_verified = flags & TODO_verify_all;
1278 }
1279
1280 /* Perform all TODO actions. */
1281 static void
1282 execute_todo (unsigned int flags)
1283 {
1284 #if defined ENABLE_CHECKING
1285 if (cfun
1286 && need_ssa_update_p (cfun))
1287 gcc_assert (flags & TODO_update_ssa_any);
1288 #endif
1289
1290 /* Inform the pass whether it is the first time it is run. */
1291 first_pass_instance = (flags & TODO_mark_first_instance) != 0;
1292
1293 statistics_fini_pass ();
1294
1295 do_per_function (execute_function_todo, (void *)(size_t) flags);
1296
1297 /* Always remove functions just as before inlining: IPA passes might be
1298 interested to see bodies of extern inline functions that are not inlined
1299 to analyze side effects. The full removal is done just at the end
1300 of IPA pass queue. */
1301 if (flags & TODO_remove_functions)
1302 {
1303 gcc_assert (!cfun);
1304 cgraph_remove_unreachable_nodes (true, dump_file);
1305 }
1306
1307 if ((flags & TODO_dump_cgraph) && dump_file && !current_function_decl)
1308 {
1309 gcc_assert (!cfun);
1310 dump_cgraph (dump_file);
1311 /* Flush the file. If verification fails, we won't be able to
1312 close the file before aborting. */
1313 fflush (dump_file);
1314 }
1315
1316 if (flags & TODO_ggc_collect)
1317 ggc_collect ();
1318
1319 /* Now that the dumping has been done, we can get rid of the optional
1320 df problems. */
1321 if (flags & TODO_df_finish)
1322 df_finish_pass ((flags & TODO_df_verify) != 0);
1323 }
1324
1325 /* Verify invariants that should hold between passes. This is a place
1326 to put simple sanity checks. */
1327
1328 static void
1329 verify_interpass_invariants (void)
1330 {
1331 #ifdef ENABLE_CHECKING
1332 gcc_assert (!fold_deferring_overflow_warnings_p ());
1333 #endif
1334 }
1335
1336 /* Clear the last verified flag. */
1337
1338 static void
1339 clear_last_verified (void *data ATTRIBUTE_UNUSED)
1340 {
1341 cfun->last_verified = 0;
1342 }
1343
1344 /* Helper function. Verify that the properties has been turn into the
1345 properties expected by the pass. */
1346
1347 #ifdef ENABLE_CHECKING
1348 static void
1349 verify_curr_properties (void *data)
1350 {
1351 unsigned int props = (size_t)data;
1352 gcc_assert ((cfun->curr_properties & props) == props);
1353 }
1354 #endif
1355
1356 /* Initialize pass dump file. */
1357 /* This is non-static so that the plugins can use it. */
1358
1359 bool
1360 pass_init_dump_file (struct opt_pass *pass)
1361 {
1362 /* If a dump file name is present, open it if enabled. */
1363 if (pass->static_pass_number != -1)
1364 {
1365 bool initializing_dump = !dump_initialized_p (pass->static_pass_number);
1366 dump_file_name = get_dump_file_name (pass->static_pass_number);
1367 dump_file = dump_begin (pass->static_pass_number, &dump_flags);
1368 if (dump_file && current_function_decl)
1369 {
1370 const char *dname, *aname;
1371 struct cgraph_node *node = cgraph_node (current_function_decl);
1372 dname = lang_hooks.decl_printable_name (current_function_decl, 2);
1373 aname = (IDENTIFIER_POINTER
1374 (DECL_ASSEMBLER_NAME (current_function_decl)));
1375 fprintf (dump_file, "\n;; Function %s (%s)%s\n\n", dname, aname,
1376 node->frequency == NODE_FREQUENCY_HOT
1377 ? " (hot)"
1378 : node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED
1379 ? " (unlikely executed)"
1380 : node->frequency == NODE_FREQUENCY_EXECUTED_ONCE
1381 ? " (executed once)"
1382 : "");
1383 }
1384 return initializing_dump;
1385 }
1386 else
1387 return false;
1388 }
1389
1390 /* Flush PASS dump file. */
1391 /* This is non-static so that plugins can use it. */
1392
1393 void
1394 pass_fini_dump_file (struct opt_pass *pass)
1395 {
1396 /* Flush and close dump file. */
1397 if (dump_file_name)
1398 {
1399 free (CONST_CAST (char *, dump_file_name));
1400 dump_file_name = NULL;
1401 }
1402
1403 if (dump_file)
1404 {
1405 dump_end (pass->static_pass_number, dump_file);
1406 dump_file = NULL;
1407 }
1408 }
1409
1410 /* After executing the pass, apply expected changes to the function
1411 properties. */
1412
1413 static void
1414 update_properties_after_pass (void *data)
1415 {
1416 struct opt_pass *pass = (struct opt_pass *) data;
1417 cfun->curr_properties = (cfun->curr_properties | pass->properties_provided)
1418 & ~pass->properties_destroyed;
1419 }
1420
1421 /* Execute summary generation for all of the passes in IPA_PASS. */
1422
1423 void
1424 execute_ipa_summary_passes (struct ipa_opt_pass_d *ipa_pass)
1425 {
1426 while (ipa_pass)
1427 {
1428 struct opt_pass *pass = &ipa_pass->pass;
1429
1430 /* Execute all of the IPA_PASSes in the list. */
1431 if (ipa_pass->pass.type == IPA_PASS
1432 && (!pass->gate || pass->gate ())
1433 && ipa_pass->generate_summary)
1434 {
1435 pass_init_dump_file (pass);
1436
1437 /* If a timevar is present, start it. */
1438 if (pass->tv_id)
1439 timevar_push (pass->tv_id);
1440
1441 ipa_pass->generate_summary ();
1442
1443 /* Stop timevar. */
1444 if (pass->tv_id)
1445 timevar_pop (pass->tv_id);
1446
1447 pass_fini_dump_file (pass);
1448 }
1449 ipa_pass = (struct ipa_opt_pass_d *)ipa_pass->pass.next;
1450 }
1451 }
1452
1453 /* Execute IPA_PASS function transform on NODE. */
1454
1455 static void
1456 execute_one_ipa_transform_pass (struct cgraph_node *node,
1457 struct ipa_opt_pass_d *ipa_pass)
1458 {
1459 struct opt_pass *pass = &ipa_pass->pass;
1460 unsigned int todo_after = 0;
1461
1462 current_pass = pass;
1463 if (!ipa_pass->function_transform)
1464 return;
1465
1466 /* Note that the folders should only create gimple expressions.
1467 This is a hack until the new folder is ready. */
1468 in_gimple_form = (cfun && (cfun->curr_properties & PROP_trees)) != 0;
1469
1470 pass_init_dump_file (pass);
1471
1472 /* Run pre-pass verification. */
1473 execute_todo (ipa_pass->function_transform_todo_flags_start);
1474
1475 /* If a timevar is present, start it. */
1476 if (pass->tv_id != TV_NONE)
1477 timevar_push (pass->tv_id);
1478
1479 /* Do it! */
1480 todo_after = ipa_pass->function_transform (node);
1481
1482 /* Stop timevar. */
1483 if (pass->tv_id != TV_NONE)
1484 timevar_pop (pass->tv_id);
1485
1486 /* Run post-pass cleanup and verification. */
1487 execute_todo (todo_after);
1488 verify_interpass_invariants ();
1489
1490 pass_fini_dump_file (pass);
1491
1492 current_pass = NULL;
1493 }
1494
1495 /* For the current function, execute all ipa transforms. */
1496
1497 void
1498 execute_all_ipa_transforms (void)
1499 {
1500 struct cgraph_node *node;
1501 if (!cfun)
1502 return;
1503 node = cgraph_node (current_function_decl);
1504
1505 if (node->ipa_transforms_to_apply)
1506 {
1507 unsigned int i;
1508
1509 for (i = 0; i < VEC_length (ipa_opt_pass, node->ipa_transforms_to_apply);
1510 i++)
1511 execute_one_ipa_transform_pass (node,
1512 VEC_index (ipa_opt_pass,
1513 node->ipa_transforms_to_apply,
1514 i));
1515 VEC_free (ipa_opt_pass, heap, node->ipa_transforms_to_apply);
1516 node->ipa_transforms_to_apply = NULL;
1517 }
1518 }
1519
1520 /* Execute PASS. */
1521
1522 bool
1523 execute_one_pass (struct opt_pass *pass)
1524 {
1525 bool initializing_dump;
1526 unsigned int todo_after = 0;
1527
1528 bool gate_status;
1529
1530 /* IPA passes are executed on whole program, so cfun should be NULL.
1531 Other passes need function context set. */
1532 if (pass->type == SIMPLE_IPA_PASS || pass->type == IPA_PASS)
1533 gcc_assert (!cfun && !current_function_decl);
1534 else
1535 gcc_assert (cfun && current_function_decl);
1536
1537 current_pass = pass;
1538
1539 /* Check whether gate check should be avoided.
1540 User controls the value of the gate through the parameter "gate_status". */
1541 gate_status = (pass->gate == NULL) ? true : pass->gate();
1542
1543 /* Override gate with plugin. */
1544 invoke_plugin_callbacks (PLUGIN_OVERRIDE_GATE, &gate_status);
1545
1546 if (!gate_status)
1547 {
1548 current_pass = NULL;
1549 return false;
1550 }
1551
1552 /* Pass execution event trigger: useful to identify passes being
1553 executed. */
1554 invoke_plugin_callbacks (PLUGIN_PASS_EXECUTION, pass);
1555
1556 if (!quiet_flag && !cfun)
1557 fprintf (stderr, " <%s>", pass->name ? pass->name : "");
1558
1559 /* Note that the folders should only create gimple expressions.
1560 This is a hack until the new folder is ready. */
1561 in_gimple_form = (cfun && (cfun->curr_properties & PROP_trees)) != 0;
1562
1563 initializing_dump = pass_init_dump_file (pass);
1564
1565 /* Run pre-pass verification. */
1566 execute_todo (pass->todo_flags_start);
1567
1568 #ifdef ENABLE_CHECKING
1569 do_per_function (verify_curr_properties,
1570 (void *)(size_t)pass->properties_required);
1571 #endif
1572
1573 /* If a timevar is present, start it. */
1574 if (pass->tv_id != TV_NONE)
1575 timevar_push (pass->tv_id);
1576
1577 /* Do it! */
1578 if (pass->execute)
1579 {
1580 todo_after = pass->execute ();
1581 do_per_function (clear_last_verified, NULL);
1582 }
1583
1584 /* Stop timevar. */
1585 if (pass->tv_id != TV_NONE)
1586 timevar_pop (pass->tv_id);
1587
1588 do_per_function (update_properties_after_pass, pass);
1589
1590 if (initializing_dump
1591 && dump_file
1592 && graph_dump_format != no_graph
1593 && cfun
1594 && (cfun->curr_properties & (PROP_cfg | PROP_rtl))
1595 == (PROP_cfg | PROP_rtl))
1596 {
1597 get_dump_file_info (pass->static_pass_number)->flags |= TDF_GRAPH;
1598 dump_flags |= TDF_GRAPH;
1599 clean_graph_dump_file (dump_file_name);
1600 }
1601
1602 /* Run post-pass cleanup and verification. */
1603 execute_todo (todo_after | pass->todo_flags_finish);
1604 verify_interpass_invariants ();
1605 if (pass->type == IPA_PASS)
1606 {
1607 struct cgraph_node *node;
1608 for (node = cgraph_nodes; node; node = node->next)
1609 if (node->analyzed)
1610 VEC_safe_push (ipa_opt_pass, heap, node->ipa_transforms_to_apply,
1611 (struct ipa_opt_pass_d *)pass);
1612 }
1613
1614 if (!current_function_decl)
1615 cgraph_process_new_functions ();
1616
1617 pass_fini_dump_file (pass);
1618
1619 if (pass->type != SIMPLE_IPA_PASS && pass->type != IPA_PASS)
1620 gcc_assert (!(cfun->curr_properties & PROP_trees)
1621 || pass->type != RTL_PASS);
1622
1623 current_pass = NULL;
1624
1625 return true;
1626 }
1627
1628 void
1629 execute_pass_list (struct opt_pass *pass)
1630 {
1631 do
1632 {
1633 gcc_assert (pass->type == GIMPLE_PASS
1634 || pass->type == RTL_PASS);
1635 if (execute_one_pass (pass) && pass->sub)
1636 execute_pass_list (pass->sub);
1637 pass = pass->next;
1638 }
1639 while (pass);
1640 }
1641
1642 /* Same as execute_pass_list but assume that subpasses of IPA passes
1643 are local passes. If SET is not NULL, write out summaries of only
1644 those node in SET. */
1645
1646 static void
1647 ipa_write_summaries_2 (struct opt_pass *pass, cgraph_node_set set,
1648 varpool_node_set vset,
1649 struct lto_out_decl_state *state)
1650 {
1651 while (pass)
1652 {
1653 struct ipa_opt_pass_d *ipa_pass = (struct ipa_opt_pass_d *)pass;
1654 gcc_assert (!current_function_decl);
1655 gcc_assert (!cfun);
1656 gcc_assert (pass->type == SIMPLE_IPA_PASS || pass->type == IPA_PASS);
1657 if (pass->type == IPA_PASS
1658 && ipa_pass->write_summary
1659 && (!pass->gate || pass->gate ()))
1660 {
1661 /* If a timevar is present, start it. */
1662 if (pass->tv_id)
1663 timevar_push (pass->tv_id);
1664
1665 pass_init_dump_file (pass);
1666
1667 ipa_pass->write_summary (set,vset);
1668
1669 pass_fini_dump_file (pass);
1670
1671 /* If a timevar is present, start it. */
1672 if (pass->tv_id)
1673 timevar_pop (pass->tv_id);
1674 }
1675
1676 if (pass->sub && pass->sub->type != GIMPLE_PASS)
1677 ipa_write_summaries_2 (pass->sub, set, vset, state);
1678
1679 pass = pass->next;
1680 }
1681 }
1682
1683 /* Helper function of ipa_write_summaries. Creates and destroys the
1684 decl state and calls ipa_write_summaries_2 for all passes that have
1685 summaries. SET is the set of nodes to be written. */
1686
1687 static void
1688 ipa_write_summaries_1 (cgraph_node_set set, varpool_node_set vset)
1689 {
1690 struct lto_out_decl_state *state = lto_new_out_decl_state ();
1691 compute_ltrans_boundary (state, set, vset);
1692
1693 lto_push_out_decl_state (state);
1694
1695 gcc_assert (!flag_wpa);
1696 ipa_write_summaries_2 (all_regular_ipa_passes, set, vset, state);
1697 ipa_write_summaries_2 (all_lto_gen_passes, set, vset, state);
1698
1699 gcc_assert (lto_get_out_decl_state () == state);
1700 lto_pop_out_decl_state ();
1701 lto_delete_out_decl_state (state);
1702 }
1703
1704 /* Write out summaries for all the nodes in the callgraph. */
1705
1706 void
1707 ipa_write_summaries (void)
1708 {
1709 cgraph_node_set set;
1710 varpool_node_set vset;
1711 struct cgraph_node **order;
1712 struct varpool_node *vnode;
1713 int i, order_pos;
1714
1715 if (!flag_generate_lto || seen_error ())
1716 return;
1717
1718 set = cgraph_node_set_new ();
1719
1720 /* Create the callgraph set in the same order used in
1721 cgraph_expand_all_functions. This mostly facilitates debugging,
1722 since it causes the gimple file to be processed in the same order
1723 as the source code. */
1724 order = XCNEWVEC (struct cgraph_node *, cgraph_n_nodes);
1725 order_pos = cgraph_postorder (order);
1726 gcc_assert (order_pos == cgraph_n_nodes);
1727
1728 for (i = order_pos - 1; i >= 0; i--)
1729 {
1730 struct cgraph_node *node = order[i];
1731
1732 if (node->analyzed)
1733 {
1734 /* When streaming out references to statements as part of some IPA
1735 pass summary, the statements need to have uids assigned and the
1736 following does that for all the IPA passes here. Naturally, this
1737 ordering then matches the one IPA-passes get in their stmt_fixup
1738 hooks. */
1739
1740 push_cfun (DECL_STRUCT_FUNCTION (node->decl));
1741 renumber_gimple_stmt_uids ();
1742 pop_cfun ();
1743 }
1744 if (node->analyzed)
1745 cgraph_node_set_add (set, node);
1746 }
1747 vset = varpool_node_set_new ();
1748
1749 for (vnode = varpool_nodes; vnode; vnode = vnode->next)
1750 if (vnode->needed && !vnode->alias)
1751 varpool_node_set_add (vset, vnode);
1752
1753 ipa_write_summaries_1 (set, vset);
1754
1755 free (order);
1756 ggc_free (set);
1757 ggc_free (vset);
1758 }
1759
1760 /* Same as execute_pass_list but assume that subpasses of IPA passes
1761 are local passes. If SET is not NULL, write out optimization summaries of
1762 only those node in SET. */
1763
1764 static void
1765 ipa_write_optimization_summaries_1 (struct opt_pass *pass, cgraph_node_set set,
1766 varpool_node_set vset,
1767 struct lto_out_decl_state *state)
1768 {
1769 while (pass)
1770 {
1771 struct ipa_opt_pass_d *ipa_pass = (struct ipa_opt_pass_d *)pass;
1772 gcc_assert (!current_function_decl);
1773 gcc_assert (!cfun);
1774 gcc_assert (pass->type == SIMPLE_IPA_PASS || pass->type == IPA_PASS);
1775 if (pass->type == IPA_PASS
1776 && ipa_pass->write_optimization_summary
1777 && (!pass->gate || pass->gate ()))
1778 {
1779 /* If a timevar is present, start it. */
1780 if (pass->tv_id)
1781 timevar_push (pass->tv_id);
1782
1783 pass_init_dump_file (pass);
1784
1785 ipa_pass->write_optimization_summary (set, vset);
1786
1787 pass_fini_dump_file (pass);
1788
1789 /* If a timevar is present, start it. */
1790 if (pass->tv_id)
1791 timevar_pop (pass->tv_id);
1792 }
1793
1794 if (pass->sub && pass->sub->type != GIMPLE_PASS)
1795 ipa_write_optimization_summaries_1 (pass->sub, set, vset, state);
1796
1797 pass = pass->next;
1798 }
1799 }
1800
1801 /* Write all the optimization summaries for the cgraph nodes in SET. If SET is
1802 NULL, write out all summaries of all nodes. */
1803
1804 void
1805 ipa_write_optimization_summaries (cgraph_node_set set, varpool_node_set vset)
1806 {
1807 struct lto_out_decl_state *state = lto_new_out_decl_state ();
1808 compute_ltrans_boundary (state, set, vset);
1809
1810 lto_push_out_decl_state (state);
1811
1812 gcc_assert (flag_wpa);
1813 ipa_write_optimization_summaries_1 (all_regular_ipa_passes, set, vset, state);
1814 ipa_write_optimization_summaries_1 (all_lto_gen_passes, set, vset, state);
1815
1816 gcc_assert (lto_get_out_decl_state () == state);
1817 lto_pop_out_decl_state ();
1818 lto_delete_out_decl_state (state);
1819 }
1820
1821 /* Same as execute_pass_list but assume that subpasses of IPA passes
1822 are local passes. */
1823
1824 static void
1825 ipa_read_summaries_1 (struct opt_pass *pass)
1826 {
1827 while (pass)
1828 {
1829 struct ipa_opt_pass_d *ipa_pass = (struct ipa_opt_pass_d *) pass;
1830
1831 gcc_assert (!current_function_decl);
1832 gcc_assert (!cfun);
1833 gcc_assert (pass->type == SIMPLE_IPA_PASS || pass->type == IPA_PASS);
1834
1835 if (pass->gate == NULL || pass->gate ())
1836 {
1837 if (pass->type == IPA_PASS && ipa_pass->read_summary)
1838 {
1839 /* If a timevar is present, start it. */
1840 if (pass->tv_id)
1841 timevar_push (pass->tv_id);
1842
1843 pass_init_dump_file (pass);
1844
1845 ipa_pass->read_summary ();
1846
1847 pass_fini_dump_file (pass);
1848
1849 /* Stop timevar. */
1850 if (pass->tv_id)
1851 timevar_pop (pass->tv_id);
1852 }
1853
1854 if (pass->sub && pass->sub->type != GIMPLE_PASS)
1855 ipa_read_summaries_1 (pass->sub);
1856 }
1857 pass = pass->next;
1858 }
1859 }
1860
1861
1862 /* Read all the summaries for all_regular_ipa_passes and all_lto_gen_passes. */
1863
1864 void
1865 ipa_read_summaries (void)
1866 {
1867 ipa_read_summaries_1 (all_regular_ipa_passes);
1868 ipa_read_summaries_1 (all_lto_gen_passes);
1869 }
1870
1871 /* Same as execute_pass_list but assume that subpasses of IPA passes
1872 are local passes. */
1873
1874 static void
1875 ipa_read_optimization_summaries_1 (struct opt_pass *pass)
1876 {
1877 while (pass)
1878 {
1879 struct ipa_opt_pass_d *ipa_pass = (struct ipa_opt_pass_d *) pass;
1880
1881 gcc_assert (!current_function_decl);
1882 gcc_assert (!cfun);
1883 gcc_assert (pass->type == SIMPLE_IPA_PASS || pass->type == IPA_PASS);
1884
1885 if (pass->gate == NULL || pass->gate ())
1886 {
1887 if (pass->type == IPA_PASS && ipa_pass->read_optimization_summary)
1888 {
1889 /* If a timevar is present, start it. */
1890 if (pass->tv_id)
1891 timevar_push (pass->tv_id);
1892
1893 pass_init_dump_file (pass);
1894
1895 ipa_pass->read_optimization_summary ();
1896
1897 pass_fini_dump_file (pass);
1898
1899 /* Stop timevar. */
1900 if (pass->tv_id)
1901 timevar_pop (pass->tv_id);
1902 }
1903
1904 if (pass->sub && pass->sub->type != GIMPLE_PASS)
1905 ipa_read_optimization_summaries_1 (pass->sub);
1906 }
1907 pass = pass->next;
1908 }
1909 }
1910
1911 /* Read all the summaries for all_regular_ipa_passes and all_lto_gen_passes. */
1912
1913 void
1914 ipa_read_optimization_summaries (void)
1915 {
1916 ipa_read_optimization_summaries_1 (all_regular_ipa_passes);
1917 ipa_read_optimization_summaries_1 (all_lto_gen_passes);
1918 }
1919
1920 /* Same as execute_pass_list but assume that subpasses of IPA passes
1921 are local passes. */
1922 void
1923 execute_ipa_pass_list (struct opt_pass *pass)
1924 {
1925 do
1926 {
1927 gcc_assert (!current_function_decl);
1928 gcc_assert (!cfun);
1929 gcc_assert (pass->type == SIMPLE_IPA_PASS || pass->type == IPA_PASS);
1930 if (execute_one_pass (pass) && pass->sub)
1931 {
1932 if (pass->sub->type == GIMPLE_PASS)
1933 {
1934 invoke_plugin_callbacks (PLUGIN_EARLY_GIMPLE_PASSES_START, NULL);
1935 do_per_function_toporder ((void (*)(void *))execute_pass_list,
1936 pass->sub);
1937 invoke_plugin_callbacks (PLUGIN_EARLY_GIMPLE_PASSES_END, NULL);
1938 }
1939 else if (pass->sub->type == SIMPLE_IPA_PASS
1940 || pass->sub->type == IPA_PASS)
1941 execute_ipa_pass_list (pass->sub);
1942 else
1943 gcc_unreachable ();
1944 }
1945 gcc_assert (!current_function_decl);
1946 cgraph_process_new_functions ();
1947 pass = pass->next;
1948 }
1949 while (pass);
1950 }
1951
1952 /* Execute stmt fixup hooks of all passes in PASS for NODE and STMTS. */
1953
1954 static void
1955 execute_ipa_stmt_fixups (struct opt_pass *pass,
1956 struct cgraph_node *node, gimple *stmts)
1957 {
1958 while (pass)
1959 {
1960 /* Execute all of the IPA_PASSes in the list. */
1961 if (pass->type == IPA_PASS
1962 && (!pass->gate || pass->gate ()))
1963 {
1964 struct ipa_opt_pass_d *ipa_pass = (struct ipa_opt_pass_d *) pass;
1965
1966 if (ipa_pass->stmt_fixup)
1967 {
1968 pass_init_dump_file (pass);
1969 /* If a timevar is present, start it. */
1970 if (pass->tv_id)
1971 timevar_push (pass->tv_id);
1972
1973 ipa_pass->stmt_fixup (node, stmts);
1974
1975 /* Stop timevar. */
1976 if (pass->tv_id)
1977 timevar_pop (pass->tv_id);
1978 pass_fini_dump_file (pass);
1979 }
1980 if (pass->sub)
1981 execute_ipa_stmt_fixups (pass->sub, node, stmts);
1982 }
1983 pass = pass->next;
1984 }
1985 }
1986
1987 /* Execute stmt fixup hooks of all IPA passes for NODE and STMTS. */
1988
1989 void
1990 execute_all_ipa_stmt_fixups (struct cgraph_node *node, gimple *stmts)
1991 {
1992 execute_ipa_stmt_fixups (all_regular_ipa_passes, node, stmts);
1993 }
1994
1995
1996 extern void debug_properties (unsigned int);
1997 extern void dump_properties (FILE *, unsigned int);
1998
1999 DEBUG_FUNCTION void
2000 dump_properties (FILE *dump, unsigned int props)
2001 {
2002 fprintf (dump, "Properties:\n");
2003 if (props & PROP_gimple_any)
2004 fprintf (dump, "PROP_gimple_any\n");
2005 if (props & PROP_gimple_lcf)
2006 fprintf (dump, "PROP_gimple_lcf\n");
2007 if (props & PROP_gimple_leh)
2008 fprintf (dump, "PROP_gimple_leh\n");
2009 if (props & PROP_cfg)
2010 fprintf (dump, "PROP_cfg\n");
2011 if (props & PROP_referenced_vars)
2012 fprintf (dump, "PROP_referenced_vars\n");
2013 if (props & PROP_ssa)
2014 fprintf (dump, "PROP_ssa\n");
2015 if (props & PROP_no_crit_edges)
2016 fprintf (dump, "PROP_no_crit_edges\n");
2017 if (props & PROP_rtl)
2018 fprintf (dump, "PROP_rtl\n");
2019 if (props & PROP_gimple_lomp)
2020 fprintf (dump, "PROP_gimple_lomp\n");
2021 if (props & PROP_gimple_lcx)
2022 fprintf (dump, "PROP_gimple_lcx\n");
2023 if (props & PROP_cfglayout)
2024 fprintf (dump, "PROP_cfglayout\n");
2025 }
2026
2027 DEBUG_FUNCTION void
2028 debug_properties (unsigned int props)
2029 {
2030 dump_properties (stderr, props);
2031 }
2032
2033 /* Called by local passes to see if function is called by already processed nodes.
2034 Because we process nodes in topological order, this means that function is
2035 in recursive cycle or we introduced new direct calls. */
2036 bool
2037 function_called_by_processed_nodes_p (void)
2038 {
2039 struct cgraph_edge *e;
2040 for (e = cgraph_node (current_function_decl)->callers; e; e = e->next_caller)
2041 {
2042 if (e->caller->decl == current_function_decl)
2043 continue;
2044 if (!e->caller->analyzed)
2045 continue;
2046 if (TREE_ASM_WRITTEN (e->caller->decl))
2047 continue;
2048 if (!e->caller->process && !e->caller->global.inlined_to)
2049 break;
2050 }
2051 if (dump_file && e)
2052 {
2053 fprintf (dump_file, "Already processed call to:\n");
2054 dump_cgraph_node (dump_file, e->caller);
2055 }
2056 return e != NULL;
2057 }
2058
2059 #include "gt-passes.h"