comparison gcc/passes.c @ 57:326d9e06c2e3

modify c-parser.c
author ryoma <e075725@ie.u-ryukyu.ac.jp>
date Mon, 15 Feb 2010 00:54:17 +0900
parents caeb520cebed 77e2b8dfacca
children 1b10fe6932e1
comparison
equal deleted inserted replaced
54:f62c169bbc24 57:326d9e06c2e3
82 #include "tree-flow.h" 82 #include "tree-flow.h"
83 #include "tree-pass.h" 83 #include "tree-pass.h"
84 #include "tree-dump.h" 84 #include "tree-dump.h"
85 #include "df.h" 85 #include "df.h"
86 #include "predict.h" 86 #include "predict.h"
87 #include "lto-streamer.h"
88 #include "plugin.h"
87 89
88 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO) 90 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
89 #include "dwarf2out.h" 91 #include "dwarf2out.h"
90 #endif 92 #endif
91 93
101 #include "xcoffout.h" /* Needed for external data 103 #include "xcoffout.h" /* Needed for external data
102 declarations for e.g. AIX 4.x. */ 104 declarations for e.g. AIX 4.x. */
103 #endif 105 #endif
104 106
105 /* This is used for debugging. It allows the current pass to printed 107 /* This is used for debugging. It allows the current pass to printed
106 from anywhere in compilation. */ 108 from anywhere in compilation.
109 The variable current_pass is also used for statistics and plugins. */
107 struct opt_pass *current_pass; 110 struct opt_pass *current_pass;
108 111
109 /* Call from anywhere to find out what pass this is. Useful for 112 /* Call from anywhere to find out what pass this is. Useful for
110 printing out debugging information deep inside an service 113 printing out debugging information deep inside an service
111 routine. */ 114 routine. */
112 void 115 void
113 print_current_pass (FILE *file) 116 print_current_pass (FILE *file)
114 { 117 {
115 if (current_pass) 118 if (current_pass)
116 fprintf (file, "current pass = %s (%d)\n", 119 fprintf (file, "current pass = %s (%d)\n",
117 current_pass->name, current_pass->static_pass_number); 120 current_pass->name, current_pass->static_pass_number);
118 else 121 else
119 fprintf (file, "no current pass.\n"); 122 fprintf (file, "no current pass.\n");
120 } 123 }
121 124
123 /* Call from the debugger to get the current pass name. */ 126 /* Call from the debugger to get the current pass name. */
124 void 127 void
125 debug_pass (void) 128 debug_pass (void)
126 { 129 {
127 print_current_pass (stderr); 130 print_current_pass (stderr);
128 } 131 }
129 132
130 133
131 134
132 /* Global variables used to communicate with passes. */ 135 /* Global variables used to communicate with passes. */
133 int dump_flags; 136 int dump_flags;
237 240
238 241
239 void 242 void
240 finish_optimization_passes (void) 243 finish_optimization_passes (void)
241 { 244 {
242 enum tree_dump_index i; 245 int i;
243 struct dump_file_info *dfi; 246 struct dump_file_info *dfi;
244 char *name; 247 char *name;
245 248
246 timevar_push (TV_DUMP); 249 timevar_push (TV_DUMP);
247 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities) 250 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
286 289
287 struct gimple_opt_pass pass_rest_of_compilation = 290 struct gimple_opt_pass pass_rest_of_compilation =
288 { 291 {
289 { 292 {
290 GIMPLE_PASS, 293 GIMPLE_PASS,
291 NULL, /* name */ 294 "*rest_of_compilation", /* name */
292 gate_rest_of_compilation, /* gate */ 295 gate_rest_of_compilation, /* gate */
293 NULL, /* execute */ 296 NULL, /* execute */
294 NULL, /* sub */ 297 NULL, /* sub */
295 NULL, /* next */ 298 NULL, /* next */
296 0, /* static_pass_number */ 299 0, /* static_pass_number */
311 314
312 struct rtl_opt_pass pass_postreload = 315 struct rtl_opt_pass pass_postreload =
313 { 316 {
314 { 317 {
315 RTL_PASS, 318 RTL_PASS,
316 NULL, /* name */ 319 "*all-postreload", /* name */
317 gate_postreload, /* gate */ 320 gate_postreload, /* gate */
318 NULL, /* execute */ 321 NULL, /* execute */
319 NULL, /* sub */ 322 NULL, /* sub */
320 NULL, /* next */ 323 NULL, /* next */
321 0, /* static_pass_number */ 324 0, /* static_pass_number */
322 0, /* tv_id */ 325 TV_NONE, /* tv_id */
323 PROP_rtl, /* properties_required */ 326 PROP_rtl, /* properties_required */
324 0, /* properties_provided */ 327 0, /* properties_provided */
325 0, /* properties_destroyed */ 328 0, /* properties_destroyed */
326 0, /* todo_flags_start */ 329 0, /* todo_flags_start */
327 TODO_ggc_collect | TODO_verify_rtl_sharing /* todo_flags_finish */ 330 TODO_ggc_collect | TODO_verify_rtl_sharing /* todo_flags_finish */
329 }; 332 };
330 333
331 334
332 335
333 /* The root of the compilation pass tree, once constructed. */ 336 /* The root of the compilation pass tree, once constructed. */
334 struct opt_pass *all_passes, *all_ipa_passes, *all_lowering_passes; 337 struct opt_pass *all_passes, *all_small_ipa_passes, *all_lowering_passes,
338 *all_regular_ipa_passes, *all_lto_gen_passes;
339
340 /* This is used by plugins, and should also be used in register_pass. */
341 #define DEF_PASS_LIST(LIST) &LIST,
342 struct opt_pass **gcc_pass_lists[] = { GCC_PASS_LISTS NULL };
343 #undef DEF_PASS_LIST
335 344
336 /* A map from static pass id to optimization pass. */ 345 /* A map from static pass id to optimization pass. */
337 struct opt_pass **passes_by_id; 346 struct opt_pass **passes_by_id;
338 int passes_by_id_size; 347 int passes_by_id_size;
339 348
366 375
367 /* Iterate over the pass tree allocating dump file numbers. We want 376 /* Iterate over the pass tree allocating dump file numbers. We want
368 to do this depth first, and independent of whether the pass is 377 to do this depth first, and independent of whether the pass is
369 enabled or not. */ 378 enabled or not. */
370 379
371 static void 380 void
372 register_one_dump_file (struct opt_pass *pass) 381 register_one_dump_file (struct opt_pass *pass)
373 { 382 {
374 char *dot_name, *flag_name, *glob_name; 383 char *dot_name, *flag_name, *glob_name;
375 const char *prefix; 384 const char *name, *prefix;
376 char num[10]; 385 char num[10];
377 int flags, id; 386 int flags, id;
378 387
379 /* See below in next_pass_1. */ 388 /* See below in next_pass_1. */
380 num[0] = '\0'; 389 num[0] = '\0';
381 if (pass->static_pass_number != -1) 390 if (pass->static_pass_number != -1)
382 sprintf (num, "%d", ((int) pass->static_pass_number < 0 391 sprintf (num, "%d", ((int) pass->static_pass_number < 0
383 ? 1 : pass->static_pass_number)); 392 ? 1 : pass->static_pass_number));
384 393
385 dot_name = concat (".", pass->name, num, NULL); 394 /* The name is both used to identify the pass for the purposes of plugins,
395 and to specify dump file name and option.
396 The latter two might want something short which is not quite unique; for
397 that reason, we may have a disambiguating prefix, followed by a space
398 to mark the start of the following dump file name / option string. */
399 name = strchr (pass->name, ' ');
400 name = name ? name + 1 : pass->name;
401 dot_name = concat (".", name, num, NULL);
386 if (pass->type == SIMPLE_IPA_PASS || pass->type == IPA_PASS) 402 if (pass->type == SIMPLE_IPA_PASS || pass->type == IPA_PASS)
387 prefix = "ipa-", flags = TDF_IPA; 403 prefix = "ipa-", flags = TDF_IPA;
388 else if (pass->type == GIMPLE_PASS) 404 else if (pass->type == GIMPLE_PASS)
389 prefix = "tree-", flags = TDF_TREE; 405 prefix = "tree-", flags = TDF_TREE;
390 else 406 else
391 prefix = "rtl-", flags = TDF_RTL; 407 prefix = "rtl-", flags = TDF_RTL;
392 408
393 flag_name = concat (prefix, pass->name, num, NULL); 409 flag_name = concat (prefix, name, num, NULL);
394 glob_name = concat (prefix, pass->name, NULL); 410 glob_name = concat (prefix, name, NULL);
395 id = dump_register (dot_name, flag_name, glob_name, flags); 411 id = dump_register (dot_name, flag_name, glob_name, flags);
396 set_pass_for_id (id, pass); 412 set_pass_for_id (id, pass);
397 } 413 }
398 414
399 /* Recursive worker function for register_dump_files. */ 415 /* Recursive worker function for register_dump_files. */
400 416
401 static int 417 static int
402 register_dump_files_1 (struct opt_pass *pass, int properties) 418 register_dump_files_1 (struct opt_pass *pass, int properties)
403 { 419 {
404 do 420 do
405 { 421 {
406 int new_properties = (properties | pass->properties_provided) 422 int new_properties = (properties | pass->properties_provided)
424 while (pass); 440 while (pass);
425 441
426 return properties; 442 return properties;
427 } 443 }
428 444
429 /* Register the dump files for the pipeline starting at PASS. 445 /* Register the dump files for the pipeline starting at PASS.
430 PROPERTIES reflects the properties that are guaranteed to be available at 446 PROPERTIES reflects the properties that are guaranteed to be available at
431 the beginning of the pipeline. */ 447 the beginning of the pipeline. */
432 448
433 static void 449 static void
434 register_dump_files (struct opt_pass *pass,int properties) 450 register_dump_files (struct opt_pass *pass,int properties)
435 { 451 {
436 pass->properties_required |= properties; 452 pass->properties_required |= properties;
437 register_dump_files_1 (pass, properties); 453 register_dump_files_1 (pass, properties);
438 } 454 }
439 455
440 /* Add a pass to the pass list. Duplicate the pass if it's already 456 /* Look at the static_pass_number and duplicate the pass
441 in the list. */ 457 if it is already added to a list. */
442 458
443 static struct opt_pass ** 459 static struct opt_pass *
444 next_pass_1 (struct opt_pass **list, struct opt_pass *pass) 460 make_pass_instance (struct opt_pass *pass, bool track_duplicates)
445 { 461 {
446 /* A nonzero static_pass_number indicates that the 462 /* A nonzero static_pass_number indicates that the
447 pass is already in the list. */ 463 pass is already in the list. */
448 if (pass->static_pass_number) 464 if (pass->static_pass_number)
449 { 465 {
450 struct opt_pass *new_pass; 466 struct opt_pass *new_pass;
451 467
452 new_pass = XNEW (struct opt_pass); 468 if (pass->type == GIMPLE_PASS
453 memcpy (new_pass, pass, sizeof (*new_pass)); 469 || pass->type == RTL_PASS
470 || pass->type == SIMPLE_IPA_PASS)
471 {
472 new_pass = XNEW (struct opt_pass);
473 memcpy (new_pass, pass, sizeof (struct opt_pass));
474 }
475 else if (pass->type == IPA_PASS)
476 {
477 new_pass = (struct opt_pass *)XNEW (struct ipa_opt_pass_d);
478 memcpy (new_pass, pass, sizeof (struct ipa_opt_pass_d));
479 }
480 else
481 gcc_unreachable ();
482
454 new_pass->next = NULL; 483 new_pass->next = NULL;
455 484
456 new_pass->todo_flags_start &= ~TODO_mark_first_instance; 485 new_pass->todo_flags_start &= ~TODO_mark_first_instance;
457 486
458 /* Indicate to register_dump_files that this pass has duplicates, 487 /* Indicate to register_dump_files that this pass has duplicates,
459 and so it should rename the dump file. The first instance will 488 and so it should rename the dump file. The first instance will
460 be -1, and be number of duplicates = -static_pass_number - 1. 489 be -1, and be number of duplicates = -static_pass_number - 1.
461 Subsequent instances will be > 0 and just the duplicate number. */ 490 Subsequent instances will be > 0 and just the duplicate number. */
462 if (pass->name) 491 if ((pass->name && pass->name[0] != '*') || track_duplicates)
463 { 492 {
464 pass->static_pass_number -= 1; 493 pass->static_pass_number -= 1;
465 new_pass->static_pass_number = -pass->static_pass_number; 494 new_pass->static_pass_number = -pass->static_pass_number;
466 } 495 }
467 496 return new_pass;
468 *list = new_pass;
469 } 497 }
470 else 498 else
471 { 499 {
472 pass->todo_flags_start |= TODO_mark_first_instance; 500 pass->todo_flags_start |= TODO_mark_first_instance;
473 pass->static_pass_number = -1; 501 pass->static_pass_number = -1;
474 *list = pass; 502
475 } 503 invoke_plugin_callbacks (PLUGIN_NEW_PASS, pass);
476 504 }
505 return pass;
506 }
507
508 /* Add a pass to the pass list. Duplicate the pass if it's already
509 in the list. */
510
511 static struct opt_pass **
512 next_pass_1 (struct opt_pass **list, struct opt_pass *pass)
513 {
514 /* Every pass should have a name so that plugins can refer to them. */
515 gcc_assert (pass->name != NULL);
516
517 *list = make_pass_instance (pass, false);
518
477 return &(*list)->next; 519 return &(*list)->next;
478 520 }
479 } 521
480 522 /* List node for an inserted pass instance. We need to keep track of all
523 the newly-added pass instances (with 'added_pass_nodes' defined below)
524 so that we can register their dump files after pass-positioning is finished.
525 Registering dumping files needs to be post-processed or the
526 static_pass_number of the opt_pass object would be modified and mess up
527 the dump file names of future pass instances to be added. */
528
529 struct pass_list_node
530 {
531 struct opt_pass *pass;
532 struct pass_list_node *next;
533 };
534
535 static struct pass_list_node *added_pass_nodes = NULL;
536 static struct pass_list_node *prev_added_pass_node;
537
538 /* Insert the pass at the proper position. Return true if the pass
539 is successfully added.
540
541 NEW_PASS_INFO - new pass to be inserted
542 PASS_LIST - root of the pass list to insert the new pass to */
543
544 static bool
545 position_pass (struct register_pass_info *new_pass_info,
546 struct opt_pass **pass_list)
547 {
548 struct opt_pass *pass = *pass_list, *prev_pass = NULL;
549 bool success = false;
550
551 for ( ; pass; prev_pass = pass, pass = pass->next)
552 {
553 /* Check if the current pass is of the same type as the new pass and
554 matches the name and the instance number of the reference pass. */
555 if (pass->type == new_pass_info->pass->type
556 && pass->name
557 && !strcmp (pass->name, new_pass_info->reference_pass_name)
558 && ((new_pass_info->ref_pass_instance_number == 0)
559 || (new_pass_info->ref_pass_instance_number ==
560 pass->static_pass_number)
561 || (new_pass_info->ref_pass_instance_number == 1
562 && pass->todo_flags_start & TODO_mark_first_instance)))
563 {
564 struct opt_pass *new_pass;
565 struct pass_list_node *new_pass_node;
566
567 new_pass = make_pass_instance (new_pass_info->pass, true);
568
569 /* Insert the new pass instance based on the positioning op. */
570 switch (new_pass_info->pos_op)
571 {
572 case PASS_POS_INSERT_AFTER:
573 new_pass->next = pass->next;
574 pass->next = new_pass;
575
576 /* Skip newly inserted pass to avoid repeated
577 insertions in the case where the new pass and the
578 existing one have the same name. */
579 pass = new_pass;
580 break;
581 case PASS_POS_INSERT_BEFORE:
582 new_pass->next = pass;
583 if (prev_pass)
584 prev_pass->next = new_pass;
585 else
586 *pass_list = new_pass;
587 break;
588 case PASS_POS_REPLACE:
589 new_pass->next = pass->next;
590 if (prev_pass)
591 prev_pass->next = new_pass;
592 else
593 *pass_list = new_pass;
594 new_pass->sub = pass->sub;
595 new_pass->tv_id = pass->tv_id;
596 pass = new_pass;
597 break;
598 default:
599 error ("Invalid pass positioning operation");
600 return false;
601 }
602
603 /* Save the newly added pass (instance) in the added_pass_nodes
604 list so that we can register its dump file later. Note that
605 we cannot register the dump file now because doing so will modify
606 the static_pass_number of the opt_pass object and therefore
607 mess up the dump file name of future instances. */
608 new_pass_node = XCNEW (struct pass_list_node);
609 new_pass_node->pass = new_pass;
610 if (!added_pass_nodes)
611 added_pass_nodes = new_pass_node;
612 else
613 prev_added_pass_node->next = new_pass_node;
614 prev_added_pass_node = new_pass_node;
615
616 success = true;
617 }
618
619 if (pass->sub && position_pass (new_pass_info, &pass->sub))
620 success = true;
621 }
622
623 return success;
624 }
625
626 /* Hooks a new pass into the pass lists.
627
628 PASS_INFO - pass information that specifies the opt_pass object,
629 reference pass, instance number, and how to position
630 the pass */
631
632 void
633 register_pass (struct register_pass_info *pass_info)
634 {
635 /* The checks below could fail in buggy plugins. Existing GCC
636 passes should never fail these checks, so we mention plugin in
637 the messages. */
638 if (!pass_info->pass)
639 fatal_error ("plugin cannot register a missing pass");
640
641 if (!pass_info->pass->name)
642 fatal_error ("plugin cannot register an unnamed pass");
643
644 if (!pass_info->reference_pass_name)
645 fatal_error
646 ("plugin cannot register pass %qs without reference pass name",
647 pass_info->pass->name);
648
649 /* Try to insert the new pass to the pass lists. We need to check
650 all three lists as the reference pass could be in one (or all) of
651 them. */
652 if (!position_pass (pass_info, &all_lowering_passes)
653 && !position_pass (pass_info, &all_small_ipa_passes)
654 && !position_pass (pass_info, &all_regular_ipa_passes)
655 && !position_pass (pass_info, &all_lto_gen_passes)
656 && !position_pass (pass_info, &all_passes))
657 fatal_error
658 ("pass %qs not found but is referenced by new pass %qs",
659 pass_info->reference_pass_name, pass_info->pass->name);
660 else
661 {
662 /* OK, we have successfully inserted the new pass. We need to register
663 the dump files for the newly added pass and its duplicates (if any).
664 Because the registration of plugin/backend passes happens after the
665 command-line options are parsed, the options that specify single
666 pass dumping (e.g. -fdump-tree-PASSNAME) cannot be used for new
667 passes. Therefore we currently can only enable dumping of
668 new passes when the 'dump-all' flags (e.g. -fdump-tree-all)
669 are specified. While doing so, we also delete the pass_list_node
670 objects created during pass positioning. */
671 while (added_pass_nodes)
672 {
673 struct pass_list_node *next_node = added_pass_nodes->next;
674 enum tree_dump_index tdi;
675 register_one_dump_file (added_pass_nodes->pass);
676 if (added_pass_nodes->pass->type == SIMPLE_IPA_PASS
677 || added_pass_nodes->pass->type == IPA_PASS)
678 tdi = TDI_ipa_all;
679 else if (added_pass_nodes->pass->type == GIMPLE_PASS)
680 tdi = TDI_tree_all;
681 else
682 tdi = TDI_rtl_all;
683 /* Check if dump-all flag is specified. */
684 if (get_dump_file_info (tdi)->state)
685 get_dump_file_info (added_pass_nodes->pass->static_pass_number)
686 ->state = get_dump_file_info (tdi)->state;
687 XDELETE (added_pass_nodes);
688 added_pass_nodes = next_node;
689 }
690 }
691 }
481 692
482 /* Construct the pass tree. The sequencing of passes is driven by 693 /* Construct the pass tree. The sequencing of passes is driven by
483 the cgraph routines: 694 the cgraph routines:
484 695
485 cgraph_finalize_compilation_unit () 696 cgraph_finalize_compilation_unit ()
488 cgraph_lower_function (N) -> all_lowering_passes 699 cgraph_lower_function (N) -> all_lowering_passes
489 700
490 If we are optimizing, cgraph_optimize is then invoked: 701 If we are optimizing, cgraph_optimize is then invoked:
491 702
492 cgraph_optimize () 703 cgraph_optimize ()
493 ipa_passes () -> all_ipa_passes 704 ipa_passes () -> all_small_ipa_passes
494 cgraph_expand_all_functions () 705 cgraph_expand_all_functions ()
495 for each node N in the cgraph 706 for each node N in the cgraph
496 cgraph_expand_function (N) 707 cgraph_expand_function (N)
497 tree_rest_of_compilation (DECL (N)) -> all_passes 708 tree_rest_of_compilation (DECL (N)) -> all_passes
498 */ 709 */
507 /* All passes needed to lower the function into shape optimizers can 718 /* All passes needed to lower the function into shape optimizers can
508 operate on. These passes are always run first on the function, but 719 operate on. These passes are always run first on the function, but
509 backend might produce already lowered functions that are not processed 720 backend might produce already lowered functions that are not processed
510 by these passes. */ 721 by these passes. */
511 p = &all_lowering_passes; 722 p = &all_lowering_passes;
512 NEXT_PASS (pass_remove_useless_stmts); 723 NEXT_PASS (pass_warn_unused_result);
724 NEXT_PASS (pass_diagnose_omp_blocks);
513 NEXT_PASS (pass_mudflap_1); 725 NEXT_PASS (pass_mudflap_1);
514 NEXT_PASS (pass_lower_omp); 726 NEXT_PASS (pass_lower_omp);
515 NEXT_PASS (pass_lower_cf); 727 NEXT_PASS (pass_lower_cf);
516 NEXT_PASS (pass_refactor_eh); 728 NEXT_PASS (pass_refactor_eh);
517 NEXT_PASS (pass_lower_eh); 729 NEXT_PASS (pass_lower_eh);
526 NEXT_PASS (pass_build_cgraph_edges); 738 NEXT_PASS (pass_build_cgraph_edges);
527 NEXT_PASS (pass_inline_parameters); 739 NEXT_PASS (pass_inline_parameters);
528 *p = NULL; 740 *p = NULL;
529 741
530 /* Interprocedural optimization passes. */ 742 /* Interprocedural optimization passes. */
531 p = &all_ipa_passes; 743 p = &all_small_ipa_passes;
532 NEXT_PASS (pass_ipa_function_and_variable_visibility); 744 NEXT_PASS (pass_ipa_function_and_variable_visibility);
533 NEXT_PASS (pass_ipa_early_inline); 745 NEXT_PASS (pass_ipa_early_inline);
534 { 746 {
535 struct opt_pass **p = &pass_ipa_early_inline.pass.sub; 747 struct opt_pass **p = &pass_ipa_early_inline.pass.sub;
536 NEXT_PASS (pass_early_inline); 748 NEXT_PASS (pass_early_inline);
537 NEXT_PASS (pass_inline_parameters); 749 NEXT_PASS (pass_inline_parameters);
538 NEXT_PASS (pass_rebuild_cgraph_edges); 750 NEXT_PASS (pass_rebuild_cgraph_edges);
539 } 751 }
752 NEXT_PASS (pass_ipa_free_lang_data);
540 NEXT_PASS (pass_early_local_passes); 753 NEXT_PASS (pass_early_local_passes);
541 { 754 {
542 struct opt_pass **p = &pass_early_local_passes.pass.sub; 755 struct opt_pass **p = &pass_early_local_passes.pass.sub;
756 NEXT_PASS (pass_fixup_cfg);
543 NEXT_PASS (pass_tree_profile); 757 NEXT_PASS (pass_tree_profile);
544 NEXT_PASS (pass_cleanup_cfg); 758 NEXT_PASS (pass_cleanup_cfg);
545 NEXT_PASS (pass_init_datastructures); 759 NEXT_PASS (pass_init_datastructures);
546 NEXT_PASS (pass_expand_omp); 760 NEXT_PASS (pass_expand_omp);
547 761
548 NEXT_PASS (pass_referenced_vars); 762 NEXT_PASS (pass_referenced_vars);
549 NEXT_PASS (pass_reset_cc_flags);
550 NEXT_PASS (pass_build_ssa); 763 NEXT_PASS (pass_build_ssa);
551 NEXT_PASS (pass_early_warn_uninitialized); 764 NEXT_PASS (pass_early_warn_uninitialized);
765 /* Note that it is not strictly necessary to schedule an early
766 inline pass here. However, some test cases (e.g.,
767 g++.dg/other/p334435.C g++.dg/other/i386-1.C) expect extern
768 inline functions to be inlined even at -O0. This does not
769 happen during the first early inline pass. */
770 NEXT_PASS (pass_rebuild_cgraph_edges);
771 NEXT_PASS (pass_early_inline);
552 NEXT_PASS (pass_all_early_optimizations); 772 NEXT_PASS (pass_all_early_optimizations);
553 { 773 {
554 struct opt_pass **p = &pass_all_early_optimizations.pass.sub; 774 struct opt_pass **p = &pass_all_early_optimizations.pass.sub;
555 NEXT_PASS (pass_rebuild_cgraph_edges); 775 NEXT_PASS (pass_remove_cgraph_callee_edges);
556 NEXT_PASS (pass_early_inline);
557 NEXT_PASS (pass_rename_ssa_copies); 776 NEXT_PASS (pass_rename_ssa_copies);
558 NEXT_PASS (pass_ccp); 777 NEXT_PASS (pass_ccp);
559 NEXT_PASS (pass_forwprop); 778 NEXT_PASS (pass_forwprop);
560 NEXT_PASS (pass_update_address_taken); 779 /* pass_build_ealias is a dummy pass that ensures that we
780 execute TODO_rebuild_alias at this point. Re-building
781 alias information also rewrites no longer addressed
782 locals into SSA form if possible. */
783 NEXT_PASS (pass_build_ealias);
561 NEXT_PASS (pass_sra_early); 784 NEXT_PASS (pass_sra_early);
562 NEXT_PASS (pass_copy_prop); 785 NEXT_PASS (pass_copy_prop);
563 NEXT_PASS (pass_merge_phi); 786 NEXT_PASS (pass_merge_phi);
564 NEXT_PASS (pass_cd_dce); 787 NEXT_PASS (pass_cd_dce);
565 NEXT_PASS (pass_simple_dse); 788 NEXT_PASS (pass_early_ipa_sra);
566 NEXT_PASS (pass_tail_recursion); 789 NEXT_PASS (pass_tail_recursion);
567 NEXT_PASS (pass_convert_switch); 790 NEXT_PASS (pass_convert_switch);
791 NEXT_PASS (pass_cleanup_eh);
568 NEXT_PASS (pass_profile); 792 NEXT_PASS (pass_profile);
793 NEXT_PASS (pass_local_pure_const);
569 } 794 }
570 NEXT_PASS (pass_release_ssa_names); 795 NEXT_PASS (pass_release_ssa_names);
571 NEXT_PASS (pass_rebuild_cgraph_edges); 796 NEXT_PASS (pass_rebuild_cgraph_edges);
572 NEXT_PASS (pass_inline_parameters); 797 NEXT_PASS (pass_inline_parameters);
573 } 798 }
574 NEXT_PASS (pass_ipa_increase_alignment); 799 NEXT_PASS (pass_ipa_increase_alignment);
575 NEXT_PASS (pass_ipa_matrix_reorg); 800 NEXT_PASS (pass_ipa_matrix_reorg);
801 *p = NULL;
802
803 p = &all_regular_ipa_passes;
804 NEXT_PASS (pass_ipa_whole_program_visibility);
576 NEXT_PASS (pass_ipa_cp); 805 NEXT_PASS (pass_ipa_cp);
577 NEXT_PASS (pass_ipa_inline); 806 NEXT_PASS (pass_ipa_inline);
578 NEXT_PASS (pass_ipa_reference); 807 NEXT_PASS (pass_ipa_reference);
579 NEXT_PASS (pass_ipa_pure_const); 808 NEXT_PASS (pass_ipa_pure_const);
580 NEXT_PASS (pass_ipa_type_escape); 809 NEXT_PASS (pass_ipa_type_escape);
581 NEXT_PASS (pass_ipa_pta); 810 NEXT_PASS (pass_ipa_pta);
582 NEXT_PASS (pass_ipa_struct_reorg); 811 NEXT_PASS (pass_ipa_struct_reorg);
812 *p = NULL;
813
814 p = &all_lto_gen_passes;
815 NEXT_PASS (pass_ipa_lto_gimple_out);
816 NEXT_PASS (pass_ipa_lto_wpa_fixup);
817 NEXT_PASS (pass_ipa_lto_finish_out); /* This must be the last LTO pass. */
583 *p = NULL; 818 *p = NULL;
584 819
585 /* These passes are run after IPA passes on every function that is being 820 /* These passes are run after IPA passes on every function that is being
586 output to the assembler file. */ 821 output to the assembler file. */
587 p = &all_passes; 822 p = &all_passes;
823 NEXT_PASS (pass_lower_eh_dispatch);
588 NEXT_PASS (pass_all_optimizations); 824 NEXT_PASS (pass_all_optimizations);
589 { 825 {
590 struct opt_pass **p = &pass_all_optimizations.pass.sub; 826 struct opt_pass **p = &pass_all_optimizations.pass.sub;
827 NEXT_PASS (pass_remove_cgraph_callee_edges);
591 /* Initial scalar cleanups before alias computation. 828 /* Initial scalar cleanups before alias computation.
592 They ensure memory accesses are not indirect wherever possible. */ 829 They ensure memory accesses are not indirect wherever possible. */
593 NEXT_PASS (pass_strip_predict_hints); 830 NEXT_PASS (pass_strip_predict_hints);
594 NEXT_PASS (pass_update_address_taken); 831 NEXT_PASS (pass_update_address_taken);
595 NEXT_PASS (pass_rename_ssa_copies); 832 NEXT_PASS (pass_rename_ssa_copies);
596 NEXT_PASS (pass_complete_unrolli); 833 NEXT_PASS (pass_complete_unrolli);
597 NEXT_PASS (pass_ccp); 834 NEXT_PASS (pass_ccp);
598 NEXT_PASS (pass_forwprop); 835 NEXT_PASS (pass_forwprop);
599 /* Ideally the function call conditional
600 dead code elimination phase can be delayed
601 till later where potentially more opportunities
602 can be found. Due to lack of good ways to
603 update VDEFs associated with the shrink-wrapped
604 calls, it is better to do the transformation
605 here where memory SSA is not built yet. */
606 NEXT_PASS (pass_call_cdce); 836 NEXT_PASS (pass_call_cdce);
607 /* pass_build_alias is a dummy pass that ensures that we 837 /* pass_build_alias is a dummy pass that ensures that we
608 execute TODO_rebuild_alias at this point. Re-building 838 execute TODO_rebuild_alias at this point. Re-building
609 alias information also rewrites no longer addressed 839 alias information also rewrites no longer addressed
610 locals into SSA form if possible. */ 840 locals into SSA form if possible. */
623 NEXT_PASS (pass_ch); 853 NEXT_PASS (pass_ch);
624 NEXT_PASS (pass_stdarg); 854 NEXT_PASS (pass_stdarg);
625 NEXT_PASS (pass_lower_complex); 855 NEXT_PASS (pass_lower_complex);
626 NEXT_PASS (pass_sra); 856 NEXT_PASS (pass_sra);
627 NEXT_PASS (pass_rename_ssa_copies); 857 NEXT_PASS (pass_rename_ssa_copies);
858 /* The dom pass will also resolve all __builtin_constant_p calls
859 that are still there to 0. This has to be done after some
860 propagations have already run, but before some more dead code
861 is removed, and this place fits nicely. Remember this when
862 trying to move or duplicate pass_dominator somewhere earlier. */
628 NEXT_PASS (pass_dominator); 863 NEXT_PASS (pass_dominator);
629 /* The only const/copy propagation opportunities left after 864 /* The only const/copy propagation opportunities left after
630 DOM should be due to degenerate PHI nodes. So rather than 865 DOM should be due to degenerate PHI nodes. So rather than
631 run the full propagators, run a specialized pass which 866 run the full propagators, run a specialized pass which
632 only examines PHIs to discover const/copy propagation 867 only examines PHIs to discover const/copy propagation
638 NEXT_PASS (pass_forwprop); 873 NEXT_PASS (pass_forwprop);
639 NEXT_PASS (pass_phiopt); 874 NEXT_PASS (pass_phiopt);
640 NEXT_PASS (pass_object_sizes); 875 NEXT_PASS (pass_object_sizes);
641 NEXT_PASS (pass_ccp); 876 NEXT_PASS (pass_ccp);
642 NEXT_PASS (pass_copy_prop); 877 NEXT_PASS (pass_copy_prop);
643 NEXT_PASS (pass_fold_builtins);
644 NEXT_PASS (pass_cse_sincos); 878 NEXT_PASS (pass_cse_sincos);
879 NEXT_PASS (pass_optimize_bswap);
645 NEXT_PASS (pass_split_crit_edges); 880 NEXT_PASS (pass_split_crit_edges);
646 NEXT_PASS (pass_pre); 881 NEXT_PASS (pass_pre);
647 NEXT_PASS (pass_sink_code); 882 NEXT_PASS (pass_sink_code);
648 NEXT_PASS (pass_tree_loop); 883 NEXT_PASS (pass_tree_loop);
649 { 884 {
650 struct opt_pass **p = &pass_tree_loop.pass.sub; 885 struct opt_pass **p = &pass_tree_loop.pass.sub;
651 NEXT_PASS (pass_tree_loop_init); 886 NEXT_PASS (pass_tree_loop_init);
652 NEXT_PASS (pass_copy_prop); 887 NEXT_PASS (pass_copy_prop);
653 NEXT_PASS (pass_dce_loop); 888 NEXT_PASS (pass_dce_loop);
654 NEXT_PASS (pass_lim); 889 NEXT_PASS (pass_lim);
655 NEXT_PASS (pass_predcom);
656 NEXT_PASS (pass_tree_unswitch); 890 NEXT_PASS (pass_tree_unswitch);
657 NEXT_PASS (pass_scev_cprop); 891 NEXT_PASS (pass_scev_cprop);
658 NEXT_PASS (pass_empty_loop);
659 NEXT_PASS (pass_record_bounds); 892 NEXT_PASS (pass_record_bounds);
660 NEXT_PASS (pass_check_data_deps); 893 NEXT_PASS (pass_check_data_deps);
661 NEXT_PASS (pass_loop_distribution); 894 NEXT_PASS (pass_loop_distribution);
662 NEXT_PASS (pass_linear_transform); 895 NEXT_PASS (pass_linear_transform);
663 NEXT_PASS (pass_graphite_transforms); 896 NEXT_PASS (pass_graphite_transforms);
897 {
898 struct opt_pass **p = &pass_graphite_transforms.pass.sub;
899 NEXT_PASS (pass_dce_loop);
900 NEXT_PASS (pass_lim);
901 }
664 NEXT_PASS (pass_iv_canon); 902 NEXT_PASS (pass_iv_canon);
665 NEXT_PASS (pass_if_conversion); 903 NEXT_PASS (pass_if_conversion);
666 NEXT_PASS (pass_vectorize); 904 NEXT_PASS (pass_vectorize);
667 { 905 {
668 struct opt_pass **p = &pass_vectorize.pass.sub; 906 struct opt_pass **p = &pass_vectorize.pass.sub;
669 NEXT_PASS (pass_lower_vector_ssa); 907 NEXT_PASS (pass_lower_vector_ssa);
670 NEXT_PASS (pass_dce_loop); 908 NEXT_PASS (pass_dce_loop);
671 } 909 }
910 NEXT_PASS (pass_predcom);
672 NEXT_PASS (pass_complete_unroll); 911 NEXT_PASS (pass_complete_unroll);
912 NEXT_PASS (pass_slp_vectorize);
673 NEXT_PASS (pass_parallelize_loops); 913 NEXT_PASS (pass_parallelize_loops);
674 NEXT_PASS (pass_loop_prefetch); 914 NEXT_PASS (pass_loop_prefetch);
675 NEXT_PASS (pass_iv_optimize); 915 NEXT_PASS (pass_iv_optimize);
676 NEXT_PASS (pass_tree_loop_done); 916 NEXT_PASS (pass_tree_loop_done);
677 } 917 }
678 NEXT_PASS (pass_cse_reciprocals); 918 NEXT_PASS (pass_cse_reciprocals);
679 NEXT_PASS (pass_convert_to_rsqrt);
680 NEXT_PASS (pass_reassoc); 919 NEXT_PASS (pass_reassoc);
681 NEXT_PASS (pass_vrp); 920 NEXT_PASS (pass_vrp);
682 NEXT_PASS (pass_dominator); 921 NEXT_PASS (pass_dominator);
683 /* The only const/copy propagation opportunities left after 922 /* The only const/copy propagation opportunities left after
684 DOM should be due to degenerate PHI nodes. So rather than 923 DOM should be due to degenerate PHI nodes. So rather than
691 930
692 /* FIXME: If DCE is not run before checking for uninitialized uses, 931 /* FIXME: If DCE is not run before checking for uninitialized uses,
693 we may get false warnings (e.g., testsuite/gcc.dg/uninit-5.c). 932 we may get false warnings (e.g., testsuite/gcc.dg/uninit-5.c).
694 However, this also causes us to misdiagnose cases that should be 933 However, this also causes us to misdiagnose cases that should be
695 real warnings (e.g., testsuite/gcc.dg/pr18501.c). 934 real warnings (e.g., testsuite/gcc.dg/pr18501.c).
696 935
697 To fix the false positives in uninit-5.c, we would have to 936 To fix the false positives in uninit-5.c, we would have to
698 account for the predicates protecting the set and the use of each 937 account for the predicates protecting the set and the use of each
699 variable. Using a representation like Gated Single Assignment 938 variable. Using a representation like Gated Single Assignment
700 may help. */ 939 may help. */
701 NEXT_PASS (pass_late_warn_uninitialized); 940 NEXT_PASS (pass_late_warn_uninitialized);
702 NEXT_PASS (pass_dse); 941 NEXT_PASS (pass_dse);
703 NEXT_PASS (pass_forwprop); 942 NEXT_PASS (pass_forwprop);
704 NEXT_PASS (pass_phiopt); 943 NEXT_PASS (pass_phiopt);
944 NEXT_PASS (pass_fold_builtins);
705 NEXT_PASS (pass_tail_calls); 945 NEXT_PASS (pass_tail_calls);
706 NEXT_PASS (pass_rename_ssa_copies); 946 NEXT_PASS (pass_rename_ssa_copies);
707 NEXT_PASS (pass_uncprop); 947 NEXT_PASS (pass_uncprop);
708 } 948 NEXT_PASS (pass_local_pure_const);
709 NEXT_PASS (pass_del_ssa); 949 }
950 NEXT_PASS (pass_cleanup_eh);
951 NEXT_PASS (pass_lower_resx);
710 NEXT_PASS (pass_nrv); 952 NEXT_PASS (pass_nrv);
711 NEXT_PASS (pass_mark_used_blocks); 953 NEXT_PASS (pass_mudflap_2);
712 NEXT_PASS (pass_cleanup_cfg_post_optimizing); 954 NEXT_PASS (pass_cleanup_cfg_post_optimizing);
713
714 NEXT_PASS (pass_warn_function_noreturn); 955 NEXT_PASS (pass_warn_function_noreturn);
715 NEXT_PASS (pass_free_datastructures); 956
716 NEXT_PASS (pass_mudflap_2);
717
718 NEXT_PASS (pass_free_cfg_annotations);
719 NEXT_PASS (pass_expand); 957 NEXT_PASS (pass_expand);
958
720 NEXT_PASS (pass_rest_of_compilation); 959 NEXT_PASS (pass_rest_of_compilation);
721 { 960 {
722 struct opt_pass **p = &pass_rest_of_compilation.pass.sub; 961 struct opt_pass **p = &pass_rest_of_compilation.pass.sub;
723 NEXT_PASS (pass_init_function); 962 NEXT_PASS (pass_init_function);
724 NEXT_PASS (pass_jump); 963 NEXT_PASS (pass_jump);
730 NEXT_PASS (pass_jump2); 969 NEXT_PASS (pass_jump2);
731 NEXT_PASS (pass_lower_subreg); 970 NEXT_PASS (pass_lower_subreg);
732 NEXT_PASS (pass_df_initialize_opt); 971 NEXT_PASS (pass_df_initialize_opt);
733 NEXT_PASS (pass_cse); 972 NEXT_PASS (pass_cse);
734 NEXT_PASS (pass_rtl_fwprop); 973 NEXT_PASS (pass_rtl_fwprop);
735 NEXT_PASS (pass_gcse); 974 NEXT_PASS (pass_rtl_cprop);
975 NEXT_PASS (pass_rtl_pre);
976 NEXT_PASS (pass_rtl_hoist);
977 NEXT_PASS (pass_rtl_cprop);
978 NEXT_PASS (pass_rtl_store_motion);
979 NEXT_PASS (pass_cse_after_global_opts);
736 NEXT_PASS (pass_rtl_ifcvt); 980 NEXT_PASS (pass_rtl_ifcvt);
981 NEXT_PASS (pass_reginfo_init);
737 /* Perform loop optimizations. It might be better to do them a bit 982 /* Perform loop optimizations. It might be better to do them a bit
738 sooner, but we want the profile feedback to work more 983 sooner, but we want the profile feedback to work more
739 efficiently. */ 984 efficiently. */
740 NEXT_PASS (pass_loop2); 985 NEXT_PASS (pass_loop2);
741 { 986 {
747 NEXT_PASS (pass_rtl_doloop); 992 NEXT_PASS (pass_rtl_doloop);
748 NEXT_PASS (pass_rtl_loop_done); 993 NEXT_PASS (pass_rtl_loop_done);
749 *p = NULL; 994 *p = NULL;
750 } 995 }
751 NEXT_PASS (pass_web); 996 NEXT_PASS (pass_web);
752 NEXT_PASS (pass_jump_bypass); 997 NEXT_PASS (pass_rtl_cprop);
753 NEXT_PASS (pass_cse2); 998 NEXT_PASS (pass_cse2);
754 NEXT_PASS (pass_rtl_dse1); 999 NEXT_PASS (pass_rtl_dse1);
755 NEXT_PASS (pass_rtl_fwprop_addr); 1000 NEXT_PASS (pass_rtl_fwprop_addr);
756 NEXT_PASS (pass_reginfo_init);
757 NEXT_PASS (pass_inc_dec); 1001 NEXT_PASS (pass_inc_dec);
758 NEXT_PASS (pass_initialize_regs); 1002 NEXT_PASS (pass_initialize_regs);
759 NEXT_PASS (pass_outof_cfg_layout_mode);
760 NEXT_PASS (pass_ud_rtl_dce); 1003 NEXT_PASS (pass_ud_rtl_dce);
761 NEXT_PASS (pass_combine); 1004 NEXT_PASS (pass_combine);
762 NEXT_PASS (pass_if_after_combine); 1005 NEXT_PASS (pass_if_after_combine);
763 NEXT_PASS (pass_partition_blocks); 1006 NEXT_PASS (pass_partition_blocks);
764 NEXT_PASS (pass_regmove); 1007 NEXT_PASS (pass_regmove);
1008 NEXT_PASS (pass_outof_cfg_layout_mode);
765 NEXT_PASS (pass_split_all_insns); 1009 NEXT_PASS (pass_split_all_insns);
766 NEXT_PASS (pass_lower_subreg2); 1010 NEXT_PASS (pass_lower_subreg2);
767 NEXT_PASS (pass_df_initialize_no_opt); 1011 NEXT_PASS (pass_df_initialize_no_opt);
768 NEXT_PASS (pass_stack_ptr_mod); 1012 NEXT_PASS (pass_stack_ptr_mod);
769 NEXT_PASS (pass_mode_switching); 1013 NEXT_PASS (pass_mode_switching);
770 NEXT_PASS (pass_see);
771 NEXT_PASS (pass_match_asm_constraints); 1014 NEXT_PASS (pass_match_asm_constraints);
772 NEXT_PASS (pass_sms); 1015 NEXT_PASS (pass_sms);
773 NEXT_PASS (pass_sched); 1016 NEXT_PASS (pass_sched);
774 NEXT_PASS (pass_subregs_of_mode_init);
775 NEXT_PASS (pass_ira); 1017 NEXT_PASS (pass_ira);
776 NEXT_PASS (pass_subregs_of_mode_finish);
777 NEXT_PASS (pass_postreload); 1018 NEXT_PASS (pass_postreload);
778 { 1019 {
779 struct opt_pass **p = &pass_postreload.pass.sub; 1020 struct opt_pass **p = &pass_postreload.pass.sub;
780 NEXT_PASS (pass_postreload_cse); 1021 NEXT_PASS (pass_postreload_cse);
781 NEXT_PASS (pass_gcse2); 1022 NEXT_PASS (pass_gcse2);
782 NEXT_PASS (pass_split_after_reload); 1023 NEXT_PASS (pass_split_after_reload);
783 NEXT_PASS (pass_branch_target_load_optimize1); 1024 NEXT_PASS (pass_branch_target_load_optimize1);
784 NEXT_PASS (pass_thread_prologue_and_epilogue); 1025 NEXT_PASS (pass_thread_prologue_and_epilogue);
785 NEXT_PASS (pass_rtl_dse2); 1026 NEXT_PASS (pass_rtl_dse2);
786 NEXT_PASS (pass_rtl_seqabstr);
787 NEXT_PASS (pass_stack_adjustments); 1027 NEXT_PASS (pass_stack_adjustments);
788 NEXT_PASS (pass_peephole2); 1028 NEXT_PASS (pass_peephole2);
789 NEXT_PASS (pass_if_after_reload); 1029 NEXT_PASS (pass_if_after_reload);
790 NEXT_PASS (pass_regrename); 1030 NEXT_PASS (pass_regrename);
791 NEXT_PASS (pass_cprop_hardreg); 1031 NEXT_PASS (pass_cprop_hardreg);
821 1061
822 #undef NEXT_PASS 1062 #undef NEXT_PASS
823 1063
824 /* Register the passes with the tree dump code. */ 1064 /* Register the passes with the tree dump code. */
825 register_dump_files (all_lowering_passes, PROP_gimple_any); 1065 register_dump_files (all_lowering_passes, PROP_gimple_any);
826 all_lowering_passes->todo_flags_start |= TODO_set_props; 1066 register_dump_files (all_small_ipa_passes,
827 register_dump_files (all_ipa_passes,
828 PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh 1067 PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh
829 | PROP_cfg); 1068 | PROP_cfg);
830 register_dump_files (all_passes, 1069 register_dump_files (all_regular_ipa_passes,
831 PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh 1070 PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh
832 | PROP_cfg); 1071 | PROP_cfg);
1072 register_dump_files (all_lto_gen_passes,
1073 PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh
1074 | PROP_cfg);
1075 register_dump_files (all_passes,
1076 PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh
1077 | PROP_cfg);
833 } 1078 }
834 1079
835 /* If we are in IPA mode (i.e., current_function_decl is NULL), call 1080 /* If we are in IPA mode (i.e., current_function_decl is NULL), call
836 function CALLBACK for every function in the call graph. Otherwise, 1081 function CALLBACK for every function in the call graph. Otherwise,
837 call CALLBACK on the current function. */ 1082 call CALLBACK on the current function. */
838 1083
839 static void 1084 static void
840 do_per_function (void (*callback) (void *data), void *data) 1085 do_per_function (void (*callback) (void *data), void *data)
841 { 1086 {
842 if (current_function_decl) 1087 if (current_function_decl)
843 callback (data); 1088 callback (data);
844 else 1089 else
845 { 1090 {
846 struct cgraph_node *node; 1091 struct cgraph_node *node;
847 for (node = cgraph_nodes; node; node = node->next) 1092 for (node = cgraph_nodes; node; node = node->next)
848 if (node->analyzed) 1093 if (node->analyzed && gimple_has_body_p (node->decl)
1094 && (!node->clone_of || node->decl != node->clone_of->decl))
849 { 1095 {
850 push_cfun (DECL_STRUCT_FUNCTION (node->decl)); 1096 push_cfun (DECL_STRUCT_FUNCTION (node->decl));
851 current_function_decl = node->decl; 1097 current_function_decl = node->decl;
852 callback (data); 1098 callback (data);
853 free_dominance_info (CDI_DOMINATORS); 1099 if (!flag_wpa)
854 free_dominance_info (CDI_POST_DOMINATORS); 1100 {
1101 free_dominance_info (CDI_DOMINATORS);
1102 free_dominance_info (CDI_POST_DOMINATORS);
1103 }
855 current_function_decl = NULL; 1104 current_function_decl = NULL;
856 pop_cfun (); 1105 pop_cfun ();
857 ggc_collect (); 1106 ggc_collect ();
858 } 1107 }
859 } 1108 }
865 static int nnodes; 1114 static int nnodes;
866 static GTY ((length ("nnodes"))) struct cgraph_node **order; 1115 static GTY ((length ("nnodes"))) struct cgraph_node **order;
867 1116
868 /* If we are in IPA mode (i.e., current_function_decl is NULL), call 1117 /* If we are in IPA mode (i.e., current_function_decl is NULL), call
869 function CALLBACK for every function in the call graph. Otherwise, 1118 function CALLBACK for every function in the call graph. Otherwise,
870 call CALLBACK on the current function. */ 1119 call CALLBACK on the current function.
871 1120 This function is global so that plugins can use it. */
872 static void 1121 void
873 do_per_function_toporder (void (*callback) (void *data), void *data) 1122 do_per_function_toporder (void (*callback) (void *data), void *data)
874 { 1123 {
875 int i; 1124 int i;
876 1125
877 if (current_function_decl) 1126 if (current_function_decl)
880 { 1129 {
881 gcc_assert (!order); 1130 gcc_assert (!order);
882 order = GGC_NEWVEC (struct cgraph_node *, cgraph_n_nodes); 1131 order = GGC_NEWVEC (struct cgraph_node *, cgraph_n_nodes);
883 nnodes = cgraph_postorder (order); 1132 nnodes = cgraph_postorder (order);
884 for (i = nnodes - 1; i >= 0; i--) 1133 for (i = nnodes - 1; i >= 0; i--)
1134 order[i]->process = 1;
1135 for (i = nnodes - 1; i >= 0; i--)
885 { 1136 {
886 struct cgraph_node *node = order[i]; 1137 struct cgraph_node *node = order[i];
887 1138
888 /* Allow possibly removed nodes to be garbage collected. */ 1139 /* Allow possibly removed nodes to be garbage collected. */
889 order[i] = NULL; 1140 order[i] = NULL;
890 if (node->analyzed && (node->needed || node->reachable)) 1141 node->process = 0;
1142 if (node->analyzed)
891 { 1143 {
892 push_cfun (DECL_STRUCT_FUNCTION (node->decl)); 1144 push_cfun (DECL_STRUCT_FUNCTION (node->decl));
893 current_function_decl = node->decl; 1145 current_function_decl = node->decl;
894 callback (data); 1146 callback (data);
895 free_dominance_info (CDI_DOMINATORS); 1147 free_dominance_info (CDI_DOMINATORS);
924 { 1176 {
925 bool cleanup = cleanup_tree_cfg (); 1177 bool cleanup = cleanup_tree_cfg ();
926 1178
927 if (cleanup && (cfun->curr_properties & PROP_ssa)) 1179 if (cleanup && (cfun->curr_properties & PROP_ssa))
928 flags |= TODO_remove_unused_locals; 1180 flags |= TODO_remove_unused_locals;
929 1181
930 /* When cleanup_tree_cfg merges consecutive blocks, it may 1182 /* When cleanup_tree_cfg merges consecutive blocks, it may
931 perform some simplistic propagation when removing single 1183 perform some simplistic propagation when removing single
932 valued PHI nodes. This propagation may, in turn, cause the 1184 valued PHI nodes. This propagation may, in turn, cause the
933 SSA form to become out-of-date (see PR 22037). So, even 1185 SSA form to become out-of-date (see PR 22037). So, even
934 if the parent pass had not scheduled an SSA update, we may 1186 if the parent pass had not scheduled an SSA update, we may
935 still need to do one. */ 1187 still need to do one. */
936 if (!(flags & TODO_update_ssa_any) && need_ssa_update_p ()) 1188 if (!(flags & TODO_update_ssa_any) && need_ssa_update_p (cfun))
937 flags |= TODO_update_ssa; 1189 flags |= TODO_update_ssa;
938 } 1190 }
939 1191
940 if (flags & TODO_update_ssa_any) 1192 if (flags & TODO_update_ssa_any)
941 { 1193 {
942 unsigned update_flags = flags & TODO_update_ssa_any; 1194 unsigned update_flags = flags & TODO_update_ssa_any;
943 update_ssa (update_flags); 1195 update_ssa (update_flags);
944 cfun->last_verified &= ~TODO_verify_ssa; 1196 cfun->last_verified &= ~TODO_verify_ssa;
945 } 1197 }
946 1198
1199 if (flags & TODO_update_address_taken)
1200 execute_update_addresses_taken (true);
1201
947 if (flags & TODO_rebuild_alias) 1202 if (flags & TODO_rebuild_alias)
948 { 1203 {
1204 if (!(flags & TODO_update_address_taken))
1205 execute_update_addresses_taken (true);
949 compute_may_aliases (); 1206 compute_may_aliases ();
950 cfun->curr_properties |= PROP_alias; 1207 }
951 } 1208
952
953 if (flags & TODO_remove_unused_locals) 1209 if (flags & TODO_remove_unused_locals)
954 remove_unused_locals (); 1210 remove_unused_locals ();
955 1211
956 if ((flags & TODO_dump_func) && dump_file && current_function_decl) 1212 if ((flags & TODO_dump_func) && dump_file && current_function_decl)
957 { 1213 {
1015 /* Perform all TODO actions. */ 1271 /* Perform all TODO actions. */
1016 static void 1272 static void
1017 execute_todo (unsigned int flags) 1273 execute_todo (unsigned int flags)
1018 { 1274 {
1019 #if defined ENABLE_CHECKING 1275 #if defined ENABLE_CHECKING
1020 if (need_ssa_update_p ()) 1276 if (cfun
1277 && need_ssa_update_p (cfun))
1021 gcc_assert (flags & TODO_update_ssa_any); 1278 gcc_assert (flags & TODO_update_ssa_any);
1022 #endif 1279 #endif
1023 1280
1024 /* Inform the pass whether it is the first time it is run. */ 1281 /* Inform the pass whether it is the first time it is run. */
1025 first_pass_instance = (flags & TODO_mark_first_instance) != 0; 1282 first_pass_instance = (flags & TODO_mark_first_instance) != 0;
1046 } 1303 }
1047 1304
1048 if (flags & TODO_ggc_collect) 1305 if (flags & TODO_ggc_collect)
1049 ggc_collect (); 1306 ggc_collect ();
1050 1307
1051 /* Now that the dumping has been done, we can get rid of the optional 1308 /* Now that the dumping has been done, we can get rid of the optional
1052 df problems. */ 1309 df problems. */
1053 if (flags & TODO_df_finish) 1310 if (flags & TODO_df_finish)
1054 df_finish_pass ((flags & TODO_df_verify) != 0); 1311 df_finish_pass ((flags & TODO_df_verify) != 0);
1055 } 1312 }
1056 1313
1084 gcc_assert ((cfun->curr_properties & props) == props); 1341 gcc_assert ((cfun->curr_properties & props) == props);
1085 } 1342 }
1086 #endif 1343 #endif
1087 1344
1088 /* Initialize pass dump file. */ 1345 /* Initialize pass dump file. */
1089 1346 /* This is non-static so that the plugins can use it. */
1090 static bool 1347
1348 bool
1091 pass_init_dump_file (struct opt_pass *pass) 1349 pass_init_dump_file (struct opt_pass *pass)
1092 { 1350 {
1093 /* If a dump file name is present, open it if enabled. */ 1351 /* If a dump file name is present, open it if enabled. */
1094 if (pass->static_pass_number != -1) 1352 if (pass->static_pass_number != -1)
1095 { 1353 {
1114 else 1372 else
1115 return false; 1373 return false;
1116 } 1374 }
1117 1375
1118 /* Flush PASS dump file. */ 1376 /* Flush PASS dump file. */
1119 1377 /* This is non-static so that plugins can use it. */
1120 static void 1378
1379 void
1121 pass_fini_dump_file (struct opt_pass *pass) 1380 pass_fini_dump_file (struct opt_pass *pass)
1122 { 1381 {
1123 /* Flush and close dump file. */ 1382 /* Flush and close dump file. */
1124 if (dump_file_name) 1383 if (dump_file_name)
1125 { 1384 {
1143 struct opt_pass *pass = (struct opt_pass *) data; 1402 struct opt_pass *pass = (struct opt_pass *) data;
1144 cfun->curr_properties = (cfun->curr_properties | pass->properties_provided) 1403 cfun->curr_properties = (cfun->curr_properties | pass->properties_provided)
1145 & ~pass->properties_destroyed; 1404 & ~pass->properties_destroyed;
1146 } 1405 }
1147 1406
1148 /* Schedule IPA transform pass DATA for CFUN. */
1149
1150 static void
1151 add_ipa_transform_pass (void *data)
1152 {
1153 struct ipa_opt_pass *ipa_pass = (struct ipa_opt_pass *) data;
1154 VEC_safe_push (ipa_opt_pass, heap, cfun->ipa_transforms_to_apply, ipa_pass);
1155 }
1156
1157 /* Execute summary generation for all of the passes in IPA_PASS. */ 1407 /* Execute summary generation for all of the passes in IPA_PASS. */
1158 1408
1159 static void 1409 void
1160 execute_ipa_summary_passes (struct ipa_opt_pass *ipa_pass) 1410 execute_ipa_summary_passes (struct ipa_opt_pass_d *ipa_pass)
1161 { 1411 {
1162 while (ipa_pass) 1412 while (ipa_pass)
1163 { 1413 {
1164 struct opt_pass *pass = &ipa_pass->pass; 1414 struct opt_pass *pass = &ipa_pass->pass;
1165 1415
1166 /* Execute all of the IPA_PASSes in the list. */ 1416 /* Execute all of the IPA_PASSes in the list. */
1167 if (ipa_pass->pass.type == IPA_PASS 1417 if (ipa_pass->pass.type == IPA_PASS
1168 && (!pass->gate || pass->gate ())) 1418 && (!pass->gate || pass->gate ())
1419 && ipa_pass->generate_summary)
1169 { 1420 {
1170 pass_init_dump_file (pass); 1421 pass_init_dump_file (pass);
1422
1423 /* If a timevar is present, start it. */
1424 if (pass->tv_id)
1425 timevar_push (pass->tv_id);
1426
1171 ipa_pass->generate_summary (); 1427 ipa_pass->generate_summary ();
1428
1429 /* Stop timevar. */
1430 if (pass->tv_id)
1431 timevar_pop (pass->tv_id);
1432
1172 pass_fini_dump_file (pass); 1433 pass_fini_dump_file (pass);
1173 } 1434 }
1174 ipa_pass = (struct ipa_opt_pass *)ipa_pass->pass.next; 1435 ipa_pass = (struct ipa_opt_pass_d *)ipa_pass->pass.next;
1175 } 1436 }
1176 } 1437 }
1177 1438
1178 /* Execute IPA_PASS function transform on NODE. */ 1439 /* Execute IPA_PASS function transform on NODE. */
1179 1440
1180 static void 1441 static void
1181 execute_one_ipa_transform_pass (struct cgraph_node *node, 1442 execute_one_ipa_transform_pass (struct cgraph_node *node,
1182 struct ipa_opt_pass *ipa_pass) 1443 struct ipa_opt_pass_d *ipa_pass)
1183 { 1444 {
1184 struct opt_pass *pass = &ipa_pass->pass; 1445 struct opt_pass *pass = &ipa_pass->pass;
1185 unsigned int todo_after = 0; 1446 unsigned int todo_after = 0;
1186 1447
1187 current_pass = pass; 1448 current_pass = pass;
1196 1457
1197 /* Run pre-pass verification. */ 1458 /* Run pre-pass verification. */
1198 execute_todo (ipa_pass->function_transform_todo_flags_start); 1459 execute_todo (ipa_pass->function_transform_todo_flags_start);
1199 1460
1200 /* If a timevar is present, start it. */ 1461 /* If a timevar is present, start it. */
1201 if (pass->tv_id) 1462 if (pass->tv_id != TV_NONE)
1202 timevar_push (pass->tv_id); 1463 timevar_push (pass->tv_id);
1203 1464
1204 /* Do it! */ 1465 /* Do it! */
1205 todo_after = ipa_pass->function_transform (node); 1466 todo_after = ipa_pass->function_transform (node);
1206 1467
1207 /* Stop timevar. */ 1468 /* Stop timevar. */
1208 if (pass->tv_id) 1469 if (pass->tv_id != TV_NONE)
1209 timevar_pop (pass->tv_id); 1470 timevar_pop (pass->tv_id);
1210 1471
1211 /* Run post-pass cleanup and verification. */ 1472 /* Run post-pass cleanup and verification. */
1212 execute_todo (todo_after); 1473 execute_todo (todo_after);
1213 verify_interpass_invariants (); 1474 verify_interpass_invariants ();
1215 pass_fini_dump_file (pass); 1476 pass_fini_dump_file (pass);
1216 1477
1217 current_pass = NULL; 1478 current_pass = NULL;
1218 } 1479 }
1219 1480
1220 static bool 1481 /* For the current function, execute all ipa transforms. */
1482
1483 void
1484 execute_all_ipa_transforms (void)
1485 {
1486 struct cgraph_node *node;
1487 if (!cfun)
1488 return;
1489 node = cgraph_node (current_function_decl);
1490 if (node->ipa_transforms_to_apply)
1491 {
1492 unsigned int i;
1493
1494 for (i = 0; i < VEC_length (ipa_opt_pass, node->ipa_transforms_to_apply);
1495 i++)
1496 execute_one_ipa_transform_pass (node,
1497 VEC_index (ipa_opt_pass,
1498 node->ipa_transforms_to_apply,
1499 i));
1500 VEC_free (ipa_opt_pass, heap, node->ipa_transforms_to_apply);
1501 node->ipa_transforms_to_apply = NULL;
1502 }
1503 }
1504
1505 /* Execute PASS. */
1506
1507 bool
1221 execute_one_pass (struct opt_pass *pass) 1508 execute_one_pass (struct opt_pass *pass)
1222 { 1509 {
1223 bool initializing_dump; 1510 bool initializing_dump;
1224 unsigned int todo_after = 0; 1511 unsigned int todo_after = 0;
1512
1513 bool gate_status;
1225 1514
1226 /* IPA passes are executed on whole program, so cfun should be NULL. 1515 /* IPA passes are executed on whole program, so cfun should be NULL.
1227 Other passes need function context set. */ 1516 Other passes need function context set. */
1228 if (pass->type == SIMPLE_IPA_PASS || pass->type == IPA_PASS) 1517 if (pass->type == SIMPLE_IPA_PASS || pass->type == IPA_PASS)
1229 gcc_assert (!cfun && !current_function_decl); 1518 gcc_assert (!cfun && !current_function_decl);
1230 else 1519 else
1231 gcc_assert (cfun && current_function_decl); 1520 gcc_assert (cfun && current_function_decl);
1232 1521
1233 if (cfun && cfun->ipa_transforms_to_apply)
1234 {
1235 unsigned int i;
1236 struct cgraph_node *node = cgraph_node (current_function_decl);
1237
1238 for (i = 0; i < VEC_length (ipa_opt_pass, cfun->ipa_transforms_to_apply);
1239 i++)
1240 execute_one_ipa_transform_pass (node,
1241 VEC_index (ipa_opt_pass,
1242 cfun->ipa_transforms_to_apply,
1243 i));
1244 VEC_free (ipa_opt_pass, heap, cfun->ipa_transforms_to_apply);
1245 cfun->ipa_transforms_to_apply = NULL;
1246 }
1247
1248 current_pass = pass; 1522 current_pass = pass;
1249 1523
1250 /* See if we're supposed to run this pass. */ 1524 /* Check whether gate check should be avoided.
1251 if (pass->gate && !pass->gate ()) 1525 User controls the value of the gate through the parameter "gate_status". */
1252 return false; 1526 gate_status = (pass->gate == NULL) ? true : pass->gate();
1527
1528 /* Override gate with plugin. */
1529 invoke_plugin_callbacks (PLUGIN_OVERRIDE_GATE, &gate_status);
1530
1531 if (!gate_status)
1532 {
1533 current_pass = NULL;
1534 return false;
1535 }
1536
1537 /* Pass execution event trigger: useful to identify passes being
1538 executed. */
1539 invoke_plugin_callbacks (PLUGIN_PASS_EXECUTION, pass);
1253 1540
1254 if (!quiet_flag && !cfun) 1541 if (!quiet_flag && !cfun)
1255 fprintf (stderr, " <%s>", pass->name ? pass->name : ""); 1542 fprintf (stderr, " <%s>", pass->name ? pass->name : "");
1256
1257 if (pass->todo_flags_start & TODO_set_props)
1258 cfun->curr_properties = pass->properties_required;
1259 1543
1260 /* Note that the folders should only create gimple expressions. 1544 /* Note that the folders should only create gimple expressions.
1261 This is a hack until the new folder is ready. */ 1545 This is a hack until the new folder is ready. */
1262 in_gimple_form = (cfun && (cfun->curr_properties & PROP_trees)) != 0; 1546 in_gimple_form = (cfun && (cfun->curr_properties & PROP_trees)) != 0;
1547
1548 initializing_dump = pass_init_dump_file (pass);
1263 1549
1264 /* Run pre-pass verification. */ 1550 /* Run pre-pass verification. */
1265 execute_todo (pass->todo_flags_start); 1551 execute_todo (pass->todo_flags_start);
1266 1552
1267 #ifdef ENABLE_CHECKING 1553 #ifdef ENABLE_CHECKING
1268 do_per_function (verify_curr_properties, 1554 do_per_function (verify_curr_properties,
1269 (void *)(size_t)pass->properties_required); 1555 (void *)(size_t)pass->properties_required);
1270 #endif 1556 #endif
1271 1557
1272 initializing_dump = pass_init_dump_file (pass);
1273
1274 /* If a timevar is present, start it. */ 1558 /* If a timevar is present, start it. */
1275 if (pass->tv_id) 1559 if (pass->tv_id != TV_NONE)
1276 timevar_push (pass->tv_id); 1560 timevar_push (pass->tv_id);
1277 1561
1278 /* Do it! */ 1562 /* Do it! */
1279 if (pass->execute) 1563 if (pass->execute)
1280 { 1564 {
1281 todo_after = pass->execute (); 1565 todo_after = pass->execute ();
1282 do_per_function (clear_last_verified, NULL); 1566 do_per_function (clear_last_verified, NULL);
1283 } 1567 }
1284 1568
1285 /* Stop timevar. */ 1569 /* Stop timevar. */
1286 if (pass->tv_id) 1570 if (pass->tv_id != TV_NONE)
1287 timevar_pop (pass->tv_id); 1571 timevar_pop (pass->tv_id);
1288 1572
1289 do_per_function (update_properties_after_pass, pass); 1573 do_per_function (update_properties_after_pass, pass);
1290 1574
1291 if (initializing_dump 1575 if (initializing_dump
1302 1586
1303 /* Run post-pass cleanup and verification. */ 1587 /* Run post-pass cleanup and verification. */
1304 execute_todo (todo_after | pass->todo_flags_finish); 1588 execute_todo (todo_after | pass->todo_flags_finish);
1305 verify_interpass_invariants (); 1589 verify_interpass_invariants ();
1306 if (pass->type == IPA_PASS) 1590 if (pass->type == IPA_PASS)
1307 do_per_function (add_ipa_transform_pass, pass); 1591 {
1592 struct cgraph_node *node;
1593 for (node = cgraph_nodes; node; node = node->next)
1594 if (node->analyzed)
1595 VEC_safe_push (ipa_opt_pass, heap, node->ipa_transforms_to_apply,
1596 (struct ipa_opt_pass_d *)pass);
1597 }
1308 1598
1309 if (!current_function_decl) 1599 if (!current_function_decl)
1310 cgraph_process_new_functions (); 1600 cgraph_process_new_functions ();
1311 1601
1312 pass_fini_dump_file (pass); 1602 pass_fini_dump_file (pass);
1333 } 1623 }
1334 while (pass); 1624 while (pass);
1335 } 1625 }
1336 1626
1337 /* Same as execute_pass_list but assume that subpasses of IPA passes 1627 /* Same as execute_pass_list but assume that subpasses of IPA passes
1628 are local passes. If SET is not NULL, write out summaries of only
1629 those node in SET. */
1630
1631 static void
1632 ipa_write_summaries_2 (struct opt_pass *pass, cgraph_node_set set,
1633 struct lto_out_decl_state *state)
1634 {
1635 while (pass)
1636 {
1637 struct ipa_opt_pass_d *ipa_pass = (struct ipa_opt_pass_d *)pass;
1638 gcc_assert (!current_function_decl);
1639 gcc_assert (!cfun);
1640 gcc_assert (pass->type == SIMPLE_IPA_PASS || pass->type == IPA_PASS);
1641 if (pass->type == IPA_PASS
1642 && ipa_pass->write_summary
1643 && (!pass->gate || pass->gate ()))
1644 {
1645 /* If a timevar is present, start it. */
1646 if (pass->tv_id)
1647 timevar_push (pass->tv_id);
1648
1649 ipa_pass->write_summary (set);
1650
1651 /* If a timevar is present, start it. */
1652 if (pass->tv_id)
1653 timevar_pop (pass->tv_id);
1654 }
1655
1656 if (pass->sub && pass->sub->type != GIMPLE_PASS)
1657 ipa_write_summaries_2 (pass->sub, set, state);
1658
1659 pass = pass->next;
1660 }
1661 }
1662
1663 /* Helper function of ipa_write_summaries. Creates and destroys the
1664 decl state and calls ipa_write_summaries_2 for all passes that have
1665 summaries. SET is the set of nodes to be written. */
1666
1667 static void
1668 ipa_write_summaries_1 (cgraph_node_set set)
1669 {
1670 struct lto_out_decl_state *state = lto_new_out_decl_state ();
1671 lto_push_out_decl_state (state);
1672
1673 if (!flag_wpa)
1674 ipa_write_summaries_2 (all_regular_ipa_passes, set, state);
1675 ipa_write_summaries_2 (all_lto_gen_passes, set, state);
1676
1677 gcc_assert (lto_get_out_decl_state () == state);
1678 lto_pop_out_decl_state ();
1679 lto_delete_out_decl_state (state);
1680 }
1681
1682 /* Write out summaries for all the nodes in the callgraph. */
1683
1684 void
1685 ipa_write_summaries (void)
1686 {
1687 cgraph_node_set set;
1688 struct cgraph_node **order;
1689 int i, order_pos;
1690
1691 if (!flag_generate_lto || errorcount || sorrycount)
1692 return;
1693
1694 lto_new_extern_inline_states ();
1695 set = cgraph_node_set_new ();
1696
1697 /* Create the callgraph set in the same order used in
1698 cgraph_expand_all_functions. This mostly facilitates debugging,
1699 since it causes the gimple file to be processed in the same order
1700 as the source code. */
1701 order = XCNEWVEC (struct cgraph_node *, cgraph_n_nodes);
1702 order_pos = cgraph_postorder (order);
1703 gcc_assert (order_pos == cgraph_n_nodes);
1704
1705 for (i = order_pos - 1; i >= 0; i--)
1706 {
1707 struct cgraph_node *node = order[i];
1708
1709 if (node->analyzed)
1710 {
1711 /* When streaming out references to statements as part of some IPA
1712 pass summary, the statements need to have uids assigned and the
1713 following does that for all the IPA passes here. Naturally, this
1714 ordering then matches the one IPA-passes get in their stmt_fixup
1715 hooks. */
1716
1717 push_cfun (DECL_STRUCT_FUNCTION (node->decl));
1718 renumber_gimple_stmt_uids ();
1719 pop_cfun ();
1720 }
1721 cgraph_node_set_add (set, node);
1722 }
1723
1724 ipa_write_summaries_1 (set);
1725 lto_delete_extern_inline_states ();
1726
1727 free (order);
1728 ggc_free (set);
1729 }
1730
1731
1732 /* Write all the summaries for the cgraph nodes in SET. If SET is
1733 NULL, write out all summaries of all nodes. */
1734
1735 void
1736 ipa_write_summaries_of_cgraph_node_set (cgraph_node_set set)
1737 {
1738 if (flag_generate_lto && !(errorcount || sorrycount))
1739 ipa_write_summaries_1 (set);
1740 }
1741
1742 /* Same as execute_pass_list but assume that subpasses of IPA passes
1743 are local passes. */
1744
1745 static void
1746 ipa_read_summaries_1 (struct opt_pass *pass)
1747 {
1748 while (pass)
1749 {
1750 struct ipa_opt_pass_d *ipa_pass = (struct ipa_opt_pass_d *) pass;
1751
1752 gcc_assert (!current_function_decl);
1753 gcc_assert (!cfun);
1754 gcc_assert (pass->type == SIMPLE_IPA_PASS || pass->type == IPA_PASS);
1755
1756 if (pass->gate == NULL || pass->gate ())
1757 {
1758 if (pass->type == IPA_PASS && ipa_pass->read_summary)
1759 {
1760 /* If a timevar is present, start it. */
1761 if (pass->tv_id)
1762 timevar_push (pass->tv_id);
1763
1764 ipa_pass->read_summary ();
1765
1766 /* Stop timevar. */
1767 if (pass->tv_id)
1768 timevar_pop (pass->tv_id);
1769 }
1770
1771 if (pass->sub && pass->sub->type != GIMPLE_PASS)
1772 ipa_read_summaries_1 (pass->sub);
1773 }
1774 pass = pass->next;
1775 }
1776 }
1777
1778
1779 /* Read all the summaries for all_regular_ipa_passes and all_lto_gen_passes. */
1780
1781 void
1782 ipa_read_summaries (void)
1783 {
1784 if (!flag_ltrans)
1785 ipa_read_summaries_1 (all_regular_ipa_passes);
1786 ipa_read_summaries_1 (all_lto_gen_passes);
1787 }
1788
1789 /* Same as execute_pass_list but assume that subpasses of IPA passes
1338 are local passes. */ 1790 are local passes. */
1339 void 1791 void
1340 execute_ipa_pass_list (struct opt_pass *pass) 1792 execute_ipa_pass_list (struct opt_pass *pass)
1341 { 1793 {
1342 bool summaries_generated = false;
1343 do 1794 do
1344 { 1795 {
1345 gcc_assert (!current_function_decl); 1796 gcc_assert (!current_function_decl);
1346 gcc_assert (!cfun); 1797 gcc_assert (!cfun);
1347 gcc_assert (pass->type == SIMPLE_IPA_PASS || pass->type == IPA_PASS); 1798 gcc_assert (pass->type == SIMPLE_IPA_PASS || pass->type == IPA_PASS);
1348 if (pass->type == IPA_PASS && (!pass->gate || pass->gate ()))
1349 {
1350 if (!summaries_generated)
1351 {
1352 if (!quiet_flag && !cfun)
1353 fprintf (stderr, " <summary generate>");
1354 execute_ipa_summary_passes ((struct ipa_opt_pass *) pass);
1355 }
1356 summaries_generated = true;
1357 }
1358 if (execute_one_pass (pass) && pass->sub) 1799 if (execute_one_pass (pass) && pass->sub)
1359 { 1800 {
1360 if (pass->sub->type == GIMPLE_PASS) 1801 if (pass->sub->type == GIMPLE_PASS)
1361 do_per_function_toporder ((void (*)(void *))execute_pass_list, 1802 {
1362 pass->sub); 1803 invoke_plugin_callbacks (PLUGIN_EARLY_GIMPLE_PASSES_START, NULL);
1804 do_per_function_toporder ((void (*)(void *))execute_pass_list,
1805 pass->sub);
1806 invoke_plugin_callbacks (PLUGIN_EARLY_GIMPLE_PASSES_END, NULL);
1807 }
1363 else if (pass->sub->type == SIMPLE_IPA_PASS 1808 else if (pass->sub->type == SIMPLE_IPA_PASS
1364 || pass->sub->type == IPA_PASS) 1809 || pass->sub->type == IPA_PASS)
1365 execute_ipa_pass_list (pass->sub); 1810 execute_ipa_pass_list (pass->sub);
1366 else 1811 else
1367 gcc_unreachable (); 1812 gcc_unreachable ();
1368 } 1813 }
1369 if (!current_function_decl) 1814 gcc_assert (!current_function_decl);
1370 cgraph_process_new_functions (); 1815 cgraph_process_new_functions ();
1371 pass = pass->next; 1816 pass = pass->next;
1372 } 1817 }
1373 while (pass); 1818 while (pass);
1374 } 1819 }
1375 1820
1821 /* Execute stmt fixup hooks of all passes in PASS for NODE and STMTS. */
1822
1823 static void
1824 execute_ipa_stmt_fixups (struct opt_pass *pass,
1825 struct cgraph_node *node, gimple *stmts)
1826 {
1827 while (pass)
1828 {
1829 /* Execute all of the IPA_PASSes in the list. */
1830 if (pass->type == IPA_PASS
1831 && (!pass->gate || pass->gate ()))
1832 {
1833 struct ipa_opt_pass_d *ipa_pass = (struct ipa_opt_pass_d *) pass;
1834
1835 if (ipa_pass->stmt_fixup)
1836 {
1837 pass_init_dump_file (pass);
1838 /* If a timevar is present, start it. */
1839 if (pass->tv_id)
1840 timevar_push (pass->tv_id);
1841
1842 ipa_pass->stmt_fixup (node, stmts);
1843
1844 /* Stop timevar. */
1845 if (pass->tv_id)
1846 timevar_pop (pass->tv_id);
1847 pass_fini_dump_file (pass);
1848 }
1849 if (pass->sub)
1850 execute_ipa_stmt_fixups (pass->sub, node, stmts);
1851 }
1852 pass = pass->next;
1853 }
1854 }
1855
1856 /* Execute stmt fixup hooks of all IPA passes for NODE and STMTS. */
1857
1858 void
1859 execute_all_ipa_stmt_fixups (struct cgraph_node *node, gimple *stmts)
1860 {
1861 execute_ipa_stmt_fixups (all_regular_ipa_passes, node, stmts);
1862 }
1863
1864
1865 extern void debug_properties (unsigned int);
1866 extern void dump_properties (FILE *, unsigned int);
1867
1868 void
1869 dump_properties (FILE *dump, unsigned int props)
1870 {
1871 fprintf (dump, "Properties:\n");
1872 if (props & PROP_gimple_any)
1873 fprintf (dump, "PROP_gimple_any\n");
1874 if (props & PROP_gimple_lcf)
1875 fprintf (dump, "PROP_gimple_lcf\n");
1876 if (props & PROP_gimple_leh)
1877 fprintf (dump, "PROP_gimple_leh\n");
1878 if (props & PROP_cfg)
1879 fprintf (dump, "PROP_cfg\n");
1880 if (props & PROP_referenced_vars)
1881 fprintf (dump, "PROP_referenced_vars\n");
1882 if (props & PROP_ssa)
1883 fprintf (dump, "PROP_ssa\n");
1884 if (props & PROP_no_crit_edges)
1885 fprintf (dump, "PROP_no_crit_edges\n");
1886 if (props & PROP_rtl)
1887 fprintf (dump, "PROP_rtl\n");
1888 if (props & PROP_gimple_lomp)
1889 fprintf (dump, "PROP_gimple_lomp\n");
1890 }
1891
1892 void
1893 debug_properties (unsigned int props)
1894 {
1895 dump_properties (stderr, props);
1896 }
1897
1898 /* Called by local passes to see if function is called by already processed nodes.
1899 Because we process nodes in topological order, this means that function is
1900 in recursive cycle or we introduced new direct calls. */
1901 bool
1902 function_called_by_processed_nodes_p (void)
1903 {
1904 struct cgraph_edge *e;
1905 for (e = cgraph_node (current_function_decl)->callers; e; e = e->next_caller)
1906 {
1907 if (e->caller->decl == current_function_decl)
1908 continue;
1909 if (!e->caller->analyzed)
1910 continue;
1911 if (TREE_ASM_WRITTEN (e->caller->decl))
1912 continue;
1913 if (!e->caller->process && !e->caller->global.inlined_to)
1914 break;
1915 }
1916 if (dump_file && e)
1917 {
1918 fprintf (dump_file, "Already processed call to:\n");
1919 dump_cgraph_node (dump_file, e->caller);
1920 }
1921 return e != NULL;
1922 }
1923
1376 #include "gt-passes.h" 1924 #include "gt-passes.h"