Mercurial > hg > CbC > CbC_gcc
comparison gcc/passes.c @ 55:77e2b8dfacca gcc-4.4.5
update it from 4.4.3 to 4.5.0
author | ryoma <e075725@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 12 Feb 2010 23:39:51 +0900 |
parents | a06113de4d67 |
children | 326d9e06c2e3 b7f97abdc517 |
comparison
equal
deleted
inserted
replaced
52:c156f1bd5cd9 | 55:77e2b8dfacca |
---|---|
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); |
522 NEXT_PASS (pass_build_cgraph_edges); | 734 NEXT_PASS (pass_build_cgraph_edges); |
523 NEXT_PASS (pass_inline_parameters); | 735 NEXT_PASS (pass_inline_parameters); |
524 *p = NULL; | 736 *p = NULL; |
525 | 737 |
526 /* Interprocedural optimization passes. */ | 738 /* Interprocedural optimization passes. */ |
527 p = &all_ipa_passes; | 739 p = &all_small_ipa_passes; |
528 NEXT_PASS (pass_ipa_function_and_variable_visibility); | 740 NEXT_PASS (pass_ipa_function_and_variable_visibility); |
529 NEXT_PASS (pass_ipa_early_inline); | 741 NEXT_PASS (pass_ipa_early_inline); |
530 { | 742 { |
531 struct opt_pass **p = &pass_ipa_early_inline.pass.sub; | 743 struct opt_pass **p = &pass_ipa_early_inline.pass.sub; |
532 NEXT_PASS (pass_early_inline); | 744 NEXT_PASS (pass_early_inline); |
533 NEXT_PASS (pass_inline_parameters); | 745 NEXT_PASS (pass_inline_parameters); |
534 NEXT_PASS (pass_rebuild_cgraph_edges); | 746 NEXT_PASS (pass_rebuild_cgraph_edges); |
535 } | 747 } |
748 NEXT_PASS (pass_ipa_free_lang_data); | |
536 NEXT_PASS (pass_early_local_passes); | 749 NEXT_PASS (pass_early_local_passes); |
537 { | 750 { |
538 struct opt_pass **p = &pass_early_local_passes.pass.sub; | 751 struct opt_pass **p = &pass_early_local_passes.pass.sub; |
752 NEXT_PASS (pass_fixup_cfg); | |
539 NEXT_PASS (pass_tree_profile); | 753 NEXT_PASS (pass_tree_profile); |
540 NEXT_PASS (pass_cleanup_cfg); | 754 NEXT_PASS (pass_cleanup_cfg); |
541 NEXT_PASS (pass_init_datastructures); | 755 NEXT_PASS (pass_init_datastructures); |
542 NEXT_PASS (pass_expand_omp); | 756 NEXT_PASS (pass_expand_omp); |
543 | 757 |
544 NEXT_PASS (pass_referenced_vars); | 758 NEXT_PASS (pass_referenced_vars); |
545 NEXT_PASS (pass_reset_cc_flags); | |
546 NEXT_PASS (pass_build_ssa); | 759 NEXT_PASS (pass_build_ssa); |
547 NEXT_PASS (pass_early_warn_uninitialized); | 760 NEXT_PASS (pass_early_warn_uninitialized); |
761 /* Note that it is not strictly necessary to schedule an early | |
762 inline pass here. However, some test cases (e.g., | |
763 g++.dg/other/p334435.C g++.dg/other/i386-1.C) expect extern | |
764 inline functions to be inlined even at -O0. This does not | |
765 happen during the first early inline pass. */ | |
766 NEXT_PASS (pass_rebuild_cgraph_edges); | |
767 NEXT_PASS (pass_early_inline); | |
548 NEXT_PASS (pass_all_early_optimizations); | 768 NEXT_PASS (pass_all_early_optimizations); |
549 { | 769 { |
550 struct opt_pass **p = &pass_all_early_optimizations.pass.sub; | 770 struct opt_pass **p = &pass_all_early_optimizations.pass.sub; |
551 NEXT_PASS (pass_rebuild_cgraph_edges); | 771 NEXT_PASS (pass_remove_cgraph_callee_edges); |
552 NEXT_PASS (pass_early_inline); | |
553 NEXT_PASS (pass_rename_ssa_copies); | 772 NEXT_PASS (pass_rename_ssa_copies); |
554 NEXT_PASS (pass_ccp); | 773 NEXT_PASS (pass_ccp); |
555 NEXT_PASS (pass_forwprop); | 774 NEXT_PASS (pass_forwprop); |
556 NEXT_PASS (pass_update_address_taken); | 775 /* pass_build_ealias is a dummy pass that ensures that we |
776 execute TODO_rebuild_alias at this point. Re-building | |
777 alias information also rewrites no longer addressed | |
778 locals into SSA form if possible. */ | |
779 NEXT_PASS (pass_build_ealias); | |
557 NEXT_PASS (pass_sra_early); | 780 NEXT_PASS (pass_sra_early); |
558 NEXT_PASS (pass_copy_prop); | 781 NEXT_PASS (pass_copy_prop); |
559 NEXT_PASS (pass_merge_phi); | 782 NEXT_PASS (pass_merge_phi); |
560 NEXT_PASS (pass_cd_dce); | 783 NEXT_PASS (pass_cd_dce); |
561 NEXT_PASS (pass_simple_dse); | 784 NEXT_PASS (pass_early_ipa_sra); |
562 NEXT_PASS (pass_tail_recursion); | 785 NEXT_PASS (pass_tail_recursion); |
563 NEXT_PASS (pass_convert_switch); | 786 NEXT_PASS (pass_convert_switch); |
787 NEXT_PASS (pass_cleanup_eh); | |
564 NEXT_PASS (pass_profile); | 788 NEXT_PASS (pass_profile); |
789 NEXT_PASS (pass_local_pure_const); | |
565 } | 790 } |
566 NEXT_PASS (pass_release_ssa_names); | 791 NEXT_PASS (pass_release_ssa_names); |
567 NEXT_PASS (pass_rebuild_cgraph_edges); | 792 NEXT_PASS (pass_rebuild_cgraph_edges); |
568 NEXT_PASS (pass_inline_parameters); | 793 NEXT_PASS (pass_inline_parameters); |
569 } | 794 } |
570 NEXT_PASS (pass_ipa_increase_alignment); | 795 NEXT_PASS (pass_ipa_increase_alignment); |
571 NEXT_PASS (pass_ipa_matrix_reorg); | 796 NEXT_PASS (pass_ipa_matrix_reorg); |
797 *p = NULL; | |
798 | |
799 p = &all_regular_ipa_passes; | |
800 NEXT_PASS (pass_ipa_whole_program_visibility); | |
572 NEXT_PASS (pass_ipa_cp); | 801 NEXT_PASS (pass_ipa_cp); |
573 NEXT_PASS (pass_ipa_inline); | 802 NEXT_PASS (pass_ipa_inline); |
574 NEXT_PASS (pass_ipa_reference); | 803 NEXT_PASS (pass_ipa_reference); |
575 NEXT_PASS (pass_ipa_pure_const); | 804 NEXT_PASS (pass_ipa_pure_const); |
576 NEXT_PASS (pass_ipa_type_escape); | 805 NEXT_PASS (pass_ipa_type_escape); |
577 NEXT_PASS (pass_ipa_pta); | 806 NEXT_PASS (pass_ipa_pta); |
578 NEXT_PASS (pass_ipa_struct_reorg); | 807 NEXT_PASS (pass_ipa_struct_reorg); |
808 *p = NULL; | |
809 | |
810 p = &all_lto_gen_passes; | |
811 NEXT_PASS (pass_ipa_lto_gimple_out); | |
812 NEXT_PASS (pass_ipa_lto_wpa_fixup); | |
813 NEXT_PASS (pass_ipa_lto_finish_out); /* This must be the last LTO pass. */ | |
579 *p = NULL; | 814 *p = NULL; |
580 | 815 |
581 /* These passes are run after IPA passes on every function that is being | 816 /* These passes are run after IPA passes on every function that is being |
582 output to the assembler file. */ | 817 output to the assembler file. */ |
583 p = &all_passes; | 818 p = &all_passes; |
819 NEXT_PASS (pass_lower_eh_dispatch); | |
584 NEXT_PASS (pass_all_optimizations); | 820 NEXT_PASS (pass_all_optimizations); |
585 { | 821 { |
586 struct opt_pass **p = &pass_all_optimizations.pass.sub; | 822 struct opt_pass **p = &pass_all_optimizations.pass.sub; |
823 NEXT_PASS (pass_remove_cgraph_callee_edges); | |
587 /* Initial scalar cleanups before alias computation. | 824 /* Initial scalar cleanups before alias computation. |
588 They ensure memory accesses are not indirect wherever possible. */ | 825 They ensure memory accesses are not indirect wherever possible. */ |
589 NEXT_PASS (pass_strip_predict_hints); | 826 NEXT_PASS (pass_strip_predict_hints); |
590 NEXT_PASS (pass_update_address_taken); | 827 NEXT_PASS (pass_update_address_taken); |
591 NEXT_PASS (pass_rename_ssa_copies); | 828 NEXT_PASS (pass_rename_ssa_copies); |
592 NEXT_PASS (pass_complete_unrolli); | 829 NEXT_PASS (pass_complete_unrolli); |
593 NEXT_PASS (pass_ccp); | 830 NEXT_PASS (pass_ccp); |
594 NEXT_PASS (pass_forwprop); | 831 NEXT_PASS (pass_forwprop); |
595 /* Ideally the function call conditional | |
596 dead code elimination phase can be delayed | |
597 till later where potentially more opportunities | |
598 can be found. Due to lack of good ways to | |
599 update VDEFs associated with the shrink-wrapped | |
600 calls, it is better to do the transformation | |
601 here where memory SSA is not built yet. */ | |
602 NEXT_PASS (pass_call_cdce); | 832 NEXT_PASS (pass_call_cdce); |
603 /* pass_build_alias is a dummy pass that ensures that we | 833 /* pass_build_alias is a dummy pass that ensures that we |
604 execute TODO_rebuild_alias at this point. Re-building | 834 execute TODO_rebuild_alias at this point. Re-building |
605 alias information also rewrites no longer addressed | 835 alias information also rewrites no longer addressed |
606 locals into SSA form if possible. */ | 836 locals into SSA form if possible. */ |
619 NEXT_PASS (pass_ch); | 849 NEXT_PASS (pass_ch); |
620 NEXT_PASS (pass_stdarg); | 850 NEXT_PASS (pass_stdarg); |
621 NEXT_PASS (pass_lower_complex); | 851 NEXT_PASS (pass_lower_complex); |
622 NEXT_PASS (pass_sra); | 852 NEXT_PASS (pass_sra); |
623 NEXT_PASS (pass_rename_ssa_copies); | 853 NEXT_PASS (pass_rename_ssa_copies); |
854 /* The dom pass will also resolve all __builtin_constant_p calls | |
855 that are still there to 0. This has to be done after some | |
856 propagations have already run, but before some more dead code | |
857 is removed, and this place fits nicely. Remember this when | |
858 trying to move or duplicate pass_dominator somewhere earlier. */ | |
624 NEXT_PASS (pass_dominator); | 859 NEXT_PASS (pass_dominator); |
625 /* The only const/copy propagation opportunities left after | 860 /* The only const/copy propagation opportunities left after |
626 DOM should be due to degenerate PHI nodes. So rather than | 861 DOM should be due to degenerate PHI nodes. So rather than |
627 run the full propagators, run a specialized pass which | 862 run the full propagators, run a specialized pass which |
628 only examines PHIs to discover const/copy propagation | 863 only examines PHIs to discover const/copy propagation |
634 NEXT_PASS (pass_forwprop); | 869 NEXT_PASS (pass_forwprop); |
635 NEXT_PASS (pass_phiopt); | 870 NEXT_PASS (pass_phiopt); |
636 NEXT_PASS (pass_object_sizes); | 871 NEXT_PASS (pass_object_sizes); |
637 NEXT_PASS (pass_ccp); | 872 NEXT_PASS (pass_ccp); |
638 NEXT_PASS (pass_copy_prop); | 873 NEXT_PASS (pass_copy_prop); |
639 NEXT_PASS (pass_fold_builtins); | |
640 NEXT_PASS (pass_cse_sincos); | 874 NEXT_PASS (pass_cse_sincos); |
875 NEXT_PASS (pass_optimize_bswap); | |
641 NEXT_PASS (pass_split_crit_edges); | 876 NEXT_PASS (pass_split_crit_edges); |
642 NEXT_PASS (pass_pre); | 877 NEXT_PASS (pass_pre); |
643 NEXT_PASS (pass_sink_code); | 878 NEXT_PASS (pass_sink_code); |
644 NEXT_PASS (pass_tree_loop); | 879 NEXT_PASS (pass_tree_loop); |
645 { | 880 { |
646 struct opt_pass **p = &pass_tree_loop.pass.sub; | 881 struct opt_pass **p = &pass_tree_loop.pass.sub; |
647 NEXT_PASS (pass_tree_loop_init); | 882 NEXT_PASS (pass_tree_loop_init); |
648 NEXT_PASS (pass_copy_prop); | 883 NEXT_PASS (pass_copy_prop); |
649 NEXT_PASS (pass_dce_loop); | 884 NEXT_PASS (pass_dce_loop); |
650 NEXT_PASS (pass_lim); | 885 NEXT_PASS (pass_lim); |
651 NEXT_PASS (pass_predcom); | |
652 NEXT_PASS (pass_tree_unswitch); | 886 NEXT_PASS (pass_tree_unswitch); |
653 NEXT_PASS (pass_scev_cprop); | 887 NEXT_PASS (pass_scev_cprop); |
654 NEXT_PASS (pass_empty_loop); | |
655 NEXT_PASS (pass_record_bounds); | 888 NEXT_PASS (pass_record_bounds); |
656 NEXT_PASS (pass_check_data_deps); | 889 NEXT_PASS (pass_check_data_deps); |
657 NEXT_PASS (pass_loop_distribution); | 890 NEXT_PASS (pass_loop_distribution); |
658 NEXT_PASS (pass_linear_transform); | 891 NEXT_PASS (pass_linear_transform); |
659 NEXT_PASS (pass_graphite_transforms); | 892 NEXT_PASS (pass_graphite_transforms); |
893 { | |
894 struct opt_pass **p = &pass_graphite_transforms.pass.sub; | |
895 NEXT_PASS (pass_dce_loop); | |
896 NEXT_PASS (pass_lim); | |
897 } | |
660 NEXT_PASS (pass_iv_canon); | 898 NEXT_PASS (pass_iv_canon); |
661 NEXT_PASS (pass_if_conversion); | 899 NEXT_PASS (pass_if_conversion); |
662 NEXT_PASS (pass_vectorize); | 900 NEXT_PASS (pass_vectorize); |
663 { | 901 { |
664 struct opt_pass **p = &pass_vectorize.pass.sub; | 902 struct opt_pass **p = &pass_vectorize.pass.sub; |
665 NEXT_PASS (pass_lower_vector_ssa); | 903 NEXT_PASS (pass_lower_vector_ssa); |
666 NEXT_PASS (pass_dce_loop); | 904 NEXT_PASS (pass_dce_loop); |
667 } | 905 } |
906 NEXT_PASS (pass_predcom); | |
668 NEXT_PASS (pass_complete_unroll); | 907 NEXT_PASS (pass_complete_unroll); |
908 NEXT_PASS (pass_slp_vectorize); | |
669 NEXT_PASS (pass_parallelize_loops); | 909 NEXT_PASS (pass_parallelize_loops); |
670 NEXT_PASS (pass_loop_prefetch); | 910 NEXT_PASS (pass_loop_prefetch); |
671 NEXT_PASS (pass_iv_optimize); | 911 NEXT_PASS (pass_iv_optimize); |
672 NEXT_PASS (pass_tree_loop_done); | 912 NEXT_PASS (pass_tree_loop_done); |
673 } | 913 } |
674 NEXT_PASS (pass_cse_reciprocals); | 914 NEXT_PASS (pass_cse_reciprocals); |
675 NEXT_PASS (pass_convert_to_rsqrt); | |
676 NEXT_PASS (pass_reassoc); | 915 NEXT_PASS (pass_reassoc); |
677 NEXT_PASS (pass_vrp); | 916 NEXT_PASS (pass_vrp); |
678 NEXT_PASS (pass_dominator); | 917 NEXT_PASS (pass_dominator); |
679 /* The only const/copy propagation opportunities left after | 918 /* The only const/copy propagation opportunities left after |
680 DOM should be due to degenerate PHI nodes. So rather than | 919 DOM should be due to degenerate PHI nodes. So rather than |
687 | 926 |
688 /* FIXME: If DCE is not run before checking for uninitialized uses, | 927 /* FIXME: If DCE is not run before checking for uninitialized uses, |
689 we may get false warnings (e.g., testsuite/gcc.dg/uninit-5.c). | 928 we may get false warnings (e.g., testsuite/gcc.dg/uninit-5.c). |
690 However, this also causes us to misdiagnose cases that should be | 929 However, this also causes us to misdiagnose cases that should be |
691 real warnings (e.g., testsuite/gcc.dg/pr18501.c). | 930 real warnings (e.g., testsuite/gcc.dg/pr18501.c). |
692 | 931 |
693 To fix the false positives in uninit-5.c, we would have to | 932 To fix the false positives in uninit-5.c, we would have to |
694 account for the predicates protecting the set and the use of each | 933 account for the predicates protecting the set and the use of each |
695 variable. Using a representation like Gated Single Assignment | 934 variable. Using a representation like Gated Single Assignment |
696 may help. */ | 935 may help. */ |
697 NEXT_PASS (pass_late_warn_uninitialized); | 936 NEXT_PASS (pass_late_warn_uninitialized); |
698 NEXT_PASS (pass_dse); | 937 NEXT_PASS (pass_dse); |
699 NEXT_PASS (pass_forwprop); | 938 NEXT_PASS (pass_forwprop); |
700 NEXT_PASS (pass_phiopt); | 939 NEXT_PASS (pass_phiopt); |
940 NEXT_PASS (pass_fold_builtins); | |
701 NEXT_PASS (pass_tail_calls); | 941 NEXT_PASS (pass_tail_calls); |
702 NEXT_PASS (pass_rename_ssa_copies); | 942 NEXT_PASS (pass_rename_ssa_copies); |
703 NEXT_PASS (pass_uncprop); | 943 NEXT_PASS (pass_uncprop); |
704 } | 944 NEXT_PASS (pass_local_pure_const); |
705 NEXT_PASS (pass_del_ssa); | 945 } |
946 NEXT_PASS (pass_cleanup_eh); | |
947 NEXT_PASS (pass_lower_resx); | |
706 NEXT_PASS (pass_nrv); | 948 NEXT_PASS (pass_nrv); |
707 NEXT_PASS (pass_mark_used_blocks); | 949 NEXT_PASS (pass_mudflap_2); |
708 NEXT_PASS (pass_cleanup_cfg_post_optimizing); | 950 NEXT_PASS (pass_cleanup_cfg_post_optimizing); |
709 | |
710 NEXT_PASS (pass_warn_function_noreturn); | 951 NEXT_PASS (pass_warn_function_noreturn); |
711 NEXT_PASS (pass_free_datastructures); | 952 |
712 NEXT_PASS (pass_mudflap_2); | |
713 | |
714 NEXT_PASS (pass_free_cfg_annotations); | |
715 NEXT_PASS (pass_expand); | 953 NEXT_PASS (pass_expand); |
954 | |
716 NEXT_PASS (pass_rest_of_compilation); | 955 NEXT_PASS (pass_rest_of_compilation); |
717 { | 956 { |
718 struct opt_pass **p = &pass_rest_of_compilation.pass.sub; | 957 struct opt_pass **p = &pass_rest_of_compilation.pass.sub; |
719 NEXT_PASS (pass_init_function); | 958 NEXT_PASS (pass_init_function); |
720 NEXT_PASS (pass_jump); | 959 NEXT_PASS (pass_jump); |
726 NEXT_PASS (pass_jump2); | 965 NEXT_PASS (pass_jump2); |
727 NEXT_PASS (pass_lower_subreg); | 966 NEXT_PASS (pass_lower_subreg); |
728 NEXT_PASS (pass_df_initialize_opt); | 967 NEXT_PASS (pass_df_initialize_opt); |
729 NEXT_PASS (pass_cse); | 968 NEXT_PASS (pass_cse); |
730 NEXT_PASS (pass_rtl_fwprop); | 969 NEXT_PASS (pass_rtl_fwprop); |
731 NEXT_PASS (pass_gcse); | 970 NEXT_PASS (pass_rtl_cprop); |
971 NEXT_PASS (pass_rtl_pre); | |
972 NEXT_PASS (pass_rtl_hoist); | |
973 NEXT_PASS (pass_rtl_cprop); | |
974 NEXT_PASS (pass_rtl_store_motion); | |
975 NEXT_PASS (pass_cse_after_global_opts); | |
732 NEXT_PASS (pass_rtl_ifcvt); | 976 NEXT_PASS (pass_rtl_ifcvt); |
977 NEXT_PASS (pass_reginfo_init); | |
733 /* Perform loop optimizations. It might be better to do them a bit | 978 /* Perform loop optimizations. It might be better to do them a bit |
734 sooner, but we want the profile feedback to work more | 979 sooner, but we want the profile feedback to work more |
735 efficiently. */ | 980 efficiently. */ |
736 NEXT_PASS (pass_loop2); | 981 NEXT_PASS (pass_loop2); |
737 { | 982 { |
743 NEXT_PASS (pass_rtl_doloop); | 988 NEXT_PASS (pass_rtl_doloop); |
744 NEXT_PASS (pass_rtl_loop_done); | 989 NEXT_PASS (pass_rtl_loop_done); |
745 *p = NULL; | 990 *p = NULL; |
746 } | 991 } |
747 NEXT_PASS (pass_web); | 992 NEXT_PASS (pass_web); |
748 NEXT_PASS (pass_jump_bypass); | 993 NEXT_PASS (pass_rtl_cprop); |
749 NEXT_PASS (pass_cse2); | 994 NEXT_PASS (pass_cse2); |
750 NEXT_PASS (pass_rtl_dse1); | 995 NEXT_PASS (pass_rtl_dse1); |
751 NEXT_PASS (pass_rtl_fwprop_addr); | 996 NEXT_PASS (pass_rtl_fwprop_addr); |
752 NEXT_PASS (pass_reginfo_init); | |
753 NEXT_PASS (pass_inc_dec); | 997 NEXT_PASS (pass_inc_dec); |
754 NEXT_PASS (pass_initialize_regs); | 998 NEXT_PASS (pass_initialize_regs); |
755 NEXT_PASS (pass_outof_cfg_layout_mode); | |
756 NEXT_PASS (pass_ud_rtl_dce); | 999 NEXT_PASS (pass_ud_rtl_dce); |
757 NEXT_PASS (pass_combine); | 1000 NEXT_PASS (pass_combine); |
758 NEXT_PASS (pass_if_after_combine); | 1001 NEXT_PASS (pass_if_after_combine); |
759 NEXT_PASS (pass_partition_blocks); | 1002 NEXT_PASS (pass_partition_blocks); |
760 NEXT_PASS (pass_regmove); | 1003 NEXT_PASS (pass_regmove); |
1004 NEXT_PASS (pass_outof_cfg_layout_mode); | |
761 NEXT_PASS (pass_split_all_insns); | 1005 NEXT_PASS (pass_split_all_insns); |
762 NEXT_PASS (pass_lower_subreg2); | 1006 NEXT_PASS (pass_lower_subreg2); |
763 NEXT_PASS (pass_df_initialize_no_opt); | 1007 NEXT_PASS (pass_df_initialize_no_opt); |
764 NEXT_PASS (pass_stack_ptr_mod); | 1008 NEXT_PASS (pass_stack_ptr_mod); |
765 NEXT_PASS (pass_mode_switching); | 1009 NEXT_PASS (pass_mode_switching); |
766 NEXT_PASS (pass_see); | |
767 NEXT_PASS (pass_match_asm_constraints); | 1010 NEXT_PASS (pass_match_asm_constraints); |
768 NEXT_PASS (pass_sms); | 1011 NEXT_PASS (pass_sms); |
769 NEXT_PASS (pass_sched); | 1012 NEXT_PASS (pass_sched); |
770 NEXT_PASS (pass_subregs_of_mode_init); | |
771 NEXT_PASS (pass_ira); | 1013 NEXT_PASS (pass_ira); |
772 NEXT_PASS (pass_subregs_of_mode_finish); | |
773 NEXT_PASS (pass_postreload); | 1014 NEXT_PASS (pass_postreload); |
774 { | 1015 { |
775 struct opt_pass **p = &pass_postreload.pass.sub; | 1016 struct opt_pass **p = &pass_postreload.pass.sub; |
776 NEXT_PASS (pass_postreload_cse); | 1017 NEXT_PASS (pass_postreload_cse); |
777 NEXT_PASS (pass_gcse2); | 1018 NEXT_PASS (pass_gcse2); |
778 NEXT_PASS (pass_split_after_reload); | 1019 NEXT_PASS (pass_split_after_reload); |
779 NEXT_PASS (pass_branch_target_load_optimize1); | 1020 NEXT_PASS (pass_branch_target_load_optimize1); |
780 NEXT_PASS (pass_thread_prologue_and_epilogue); | 1021 NEXT_PASS (pass_thread_prologue_and_epilogue); |
781 NEXT_PASS (pass_rtl_dse2); | 1022 NEXT_PASS (pass_rtl_dse2); |
782 NEXT_PASS (pass_rtl_seqabstr); | |
783 NEXT_PASS (pass_stack_adjustments); | 1023 NEXT_PASS (pass_stack_adjustments); |
784 NEXT_PASS (pass_peephole2); | 1024 NEXT_PASS (pass_peephole2); |
785 NEXT_PASS (pass_if_after_reload); | 1025 NEXT_PASS (pass_if_after_reload); |
786 NEXT_PASS (pass_regrename); | 1026 NEXT_PASS (pass_regrename); |
787 NEXT_PASS (pass_cprop_hardreg); | 1027 NEXT_PASS (pass_cprop_hardreg); |
817 | 1057 |
818 #undef NEXT_PASS | 1058 #undef NEXT_PASS |
819 | 1059 |
820 /* Register the passes with the tree dump code. */ | 1060 /* Register the passes with the tree dump code. */ |
821 register_dump_files (all_lowering_passes, PROP_gimple_any); | 1061 register_dump_files (all_lowering_passes, PROP_gimple_any); |
822 all_lowering_passes->todo_flags_start |= TODO_set_props; | 1062 register_dump_files (all_small_ipa_passes, |
823 register_dump_files (all_ipa_passes, | |
824 PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh | 1063 PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh |
825 | PROP_cfg); | 1064 | PROP_cfg); |
826 register_dump_files (all_passes, | 1065 register_dump_files (all_regular_ipa_passes, |
827 PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh | 1066 PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh |
828 | PROP_cfg); | 1067 | PROP_cfg); |
1068 register_dump_files (all_lto_gen_passes, | |
1069 PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh | |
1070 | PROP_cfg); | |
1071 register_dump_files (all_passes, | |
1072 PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh | |
1073 | PROP_cfg); | |
829 } | 1074 } |
830 | 1075 |
831 /* If we are in IPA mode (i.e., current_function_decl is NULL), call | 1076 /* If we are in IPA mode (i.e., current_function_decl is NULL), call |
832 function CALLBACK for every function in the call graph. Otherwise, | 1077 function CALLBACK for every function in the call graph. Otherwise, |
833 call CALLBACK on the current function. */ | 1078 call CALLBACK on the current function. */ |
834 | 1079 |
835 static void | 1080 static void |
836 do_per_function (void (*callback) (void *data), void *data) | 1081 do_per_function (void (*callback) (void *data), void *data) |
837 { | 1082 { |
838 if (current_function_decl) | 1083 if (current_function_decl) |
839 callback (data); | 1084 callback (data); |
840 else | 1085 else |
841 { | 1086 { |
842 struct cgraph_node *node; | 1087 struct cgraph_node *node; |
843 for (node = cgraph_nodes; node; node = node->next) | 1088 for (node = cgraph_nodes; node; node = node->next) |
844 if (node->analyzed) | 1089 if (node->analyzed && gimple_has_body_p (node->decl) |
1090 && (!node->clone_of || node->decl != node->clone_of->decl)) | |
845 { | 1091 { |
846 push_cfun (DECL_STRUCT_FUNCTION (node->decl)); | 1092 push_cfun (DECL_STRUCT_FUNCTION (node->decl)); |
847 current_function_decl = node->decl; | 1093 current_function_decl = node->decl; |
848 callback (data); | 1094 callback (data); |
849 free_dominance_info (CDI_DOMINATORS); | 1095 if (!flag_wpa) |
850 free_dominance_info (CDI_POST_DOMINATORS); | 1096 { |
1097 free_dominance_info (CDI_DOMINATORS); | |
1098 free_dominance_info (CDI_POST_DOMINATORS); | |
1099 } | |
851 current_function_decl = NULL; | 1100 current_function_decl = NULL; |
852 pop_cfun (); | 1101 pop_cfun (); |
853 ggc_collect (); | 1102 ggc_collect (); |
854 } | 1103 } |
855 } | 1104 } |
861 static int nnodes; | 1110 static int nnodes; |
862 static GTY ((length ("nnodes"))) struct cgraph_node **order; | 1111 static GTY ((length ("nnodes"))) struct cgraph_node **order; |
863 | 1112 |
864 /* If we are in IPA mode (i.e., current_function_decl is NULL), call | 1113 /* If we are in IPA mode (i.e., current_function_decl is NULL), call |
865 function CALLBACK for every function in the call graph. Otherwise, | 1114 function CALLBACK for every function in the call graph. Otherwise, |
866 call CALLBACK on the current function. */ | 1115 call CALLBACK on the current function. |
867 | 1116 This function is global so that plugins can use it. */ |
868 static void | 1117 void |
869 do_per_function_toporder (void (*callback) (void *data), void *data) | 1118 do_per_function_toporder (void (*callback) (void *data), void *data) |
870 { | 1119 { |
871 int i; | 1120 int i; |
872 | 1121 |
873 if (current_function_decl) | 1122 if (current_function_decl) |
876 { | 1125 { |
877 gcc_assert (!order); | 1126 gcc_assert (!order); |
878 order = GGC_NEWVEC (struct cgraph_node *, cgraph_n_nodes); | 1127 order = GGC_NEWVEC (struct cgraph_node *, cgraph_n_nodes); |
879 nnodes = cgraph_postorder (order); | 1128 nnodes = cgraph_postorder (order); |
880 for (i = nnodes - 1; i >= 0; i--) | 1129 for (i = nnodes - 1; i >= 0; i--) |
1130 order[i]->process = 1; | |
1131 for (i = nnodes - 1; i >= 0; i--) | |
881 { | 1132 { |
882 struct cgraph_node *node = order[i]; | 1133 struct cgraph_node *node = order[i]; |
883 | 1134 |
884 /* Allow possibly removed nodes to be garbage collected. */ | 1135 /* Allow possibly removed nodes to be garbage collected. */ |
885 order[i] = NULL; | 1136 order[i] = NULL; |
886 if (node->analyzed && (node->needed || node->reachable)) | 1137 node->process = 0; |
1138 if (node->analyzed) | |
887 { | 1139 { |
888 push_cfun (DECL_STRUCT_FUNCTION (node->decl)); | 1140 push_cfun (DECL_STRUCT_FUNCTION (node->decl)); |
889 current_function_decl = node->decl; | 1141 current_function_decl = node->decl; |
890 callback (data); | 1142 callback (data); |
891 free_dominance_info (CDI_DOMINATORS); | 1143 free_dominance_info (CDI_DOMINATORS); |
920 { | 1172 { |
921 bool cleanup = cleanup_tree_cfg (); | 1173 bool cleanup = cleanup_tree_cfg (); |
922 | 1174 |
923 if (cleanup && (cfun->curr_properties & PROP_ssa)) | 1175 if (cleanup && (cfun->curr_properties & PROP_ssa)) |
924 flags |= TODO_remove_unused_locals; | 1176 flags |= TODO_remove_unused_locals; |
925 | 1177 |
926 /* When cleanup_tree_cfg merges consecutive blocks, it may | 1178 /* When cleanup_tree_cfg merges consecutive blocks, it may |
927 perform some simplistic propagation when removing single | 1179 perform some simplistic propagation when removing single |
928 valued PHI nodes. This propagation may, in turn, cause the | 1180 valued PHI nodes. This propagation may, in turn, cause the |
929 SSA form to become out-of-date (see PR 22037). So, even | 1181 SSA form to become out-of-date (see PR 22037). So, even |
930 if the parent pass had not scheduled an SSA update, we may | 1182 if the parent pass had not scheduled an SSA update, we may |
931 still need to do one. */ | 1183 still need to do one. */ |
932 if (!(flags & TODO_update_ssa_any) && need_ssa_update_p ()) | 1184 if (!(flags & TODO_update_ssa_any) && need_ssa_update_p (cfun)) |
933 flags |= TODO_update_ssa; | 1185 flags |= TODO_update_ssa; |
934 } | 1186 } |
935 | 1187 |
936 if (flags & TODO_update_ssa_any) | 1188 if (flags & TODO_update_ssa_any) |
937 { | 1189 { |
938 unsigned update_flags = flags & TODO_update_ssa_any; | 1190 unsigned update_flags = flags & TODO_update_ssa_any; |
939 update_ssa (update_flags); | 1191 update_ssa (update_flags); |
940 cfun->last_verified &= ~TODO_verify_ssa; | 1192 cfun->last_verified &= ~TODO_verify_ssa; |
941 } | 1193 } |
942 | 1194 |
1195 if (flags & TODO_update_address_taken) | |
1196 execute_update_addresses_taken (true); | |
1197 | |
943 if (flags & TODO_rebuild_alias) | 1198 if (flags & TODO_rebuild_alias) |
944 { | 1199 { |
1200 if (!(flags & TODO_update_address_taken)) | |
1201 execute_update_addresses_taken (true); | |
945 compute_may_aliases (); | 1202 compute_may_aliases (); |
946 cfun->curr_properties |= PROP_alias; | 1203 } |
947 } | 1204 |
948 | |
949 if (flags & TODO_remove_unused_locals) | 1205 if (flags & TODO_remove_unused_locals) |
950 remove_unused_locals (); | 1206 remove_unused_locals (); |
951 | 1207 |
952 if ((flags & TODO_dump_func) && dump_file && current_function_decl) | 1208 if ((flags & TODO_dump_func) && dump_file && current_function_decl) |
953 { | 1209 { |
1011 /* Perform all TODO actions. */ | 1267 /* Perform all TODO actions. */ |
1012 static void | 1268 static void |
1013 execute_todo (unsigned int flags) | 1269 execute_todo (unsigned int flags) |
1014 { | 1270 { |
1015 #if defined ENABLE_CHECKING | 1271 #if defined ENABLE_CHECKING |
1016 if (need_ssa_update_p ()) | 1272 if (cfun |
1273 && need_ssa_update_p (cfun)) | |
1017 gcc_assert (flags & TODO_update_ssa_any); | 1274 gcc_assert (flags & TODO_update_ssa_any); |
1018 #endif | 1275 #endif |
1019 | 1276 |
1020 /* Inform the pass whether it is the first time it is run. */ | 1277 /* Inform the pass whether it is the first time it is run. */ |
1021 first_pass_instance = (flags & TODO_mark_first_instance) != 0; | 1278 first_pass_instance = (flags & TODO_mark_first_instance) != 0; |
1042 } | 1299 } |
1043 | 1300 |
1044 if (flags & TODO_ggc_collect) | 1301 if (flags & TODO_ggc_collect) |
1045 ggc_collect (); | 1302 ggc_collect (); |
1046 | 1303 |
1047 /* Now that the dumping has been done, we can get rid of the optional | 1304 /* Now that the dumping has been done, we can get rid of the optional |
1048 df problems. */ | 1305 df problems. */ |
1049 if (flags & TODO_df_finish) | 1306 if (flags & TODO_df_finish) |
1050 df_finish_pass ((flags & TODO_df_verify) != 0); | 1307 df_finish_pass ((flags & TODO_df_verify) != 0); |
1051 } | 1308 } |
1052 | 1309 |
1080 gcc_assert ((cfun->curr_properties & props) == props); | 1337 gcc_assert ((cfun->curr_properties & props) == props); |
1081 } | 1338 } |
1082 #endif | 1339 #endif |
1083 | 1340 |
1084 /* Initialize pass dump file. */ | 1341 /* Initialize pass dump file. */ |
1085 | 1342 /* This is non-static so that the plugins can use it. */ |
1086 static bool | 1343 |
1344 bool | |
1087 pass_init_dump_file (struct opt_pass *pass) | 1345 pass_init_dump_file (struct opt_pass *pass) |
1088 { | 1346 { |
1089 /* If a dump file name is present, open it if enabled. */ | 1347 /* If a dump file name is present, open it if enabled. */ |
1090 if (pass->static_pass_number != -1) | 1348 if (pass->static_pass_number != -1) |
1091 { | 1349 { |
1110 else | 1368 else |
1111 return false; | 1369 return false; |
1112 } | 1370 } |
1113 | 1371 |
1114 /* Flush PASS dump file. */ | 1372 /* Flush PASS dump file. */ |
1115 | 1373 /* This is non-static so that plugins can use it. */ |
1116 static void | 1374 |
1375 void | |
1117 pass_fini_dump_file (struct opt_pass *pass) | 1376 pass_fini_dump_file (struct opt_pass *pass) |
1118 { | 1377 { |
1119 /* Flush and close dump file. */ | 1378 /* Flush and close dump file. */ |
1120 if (dump_file_name) | 1379 if (dump_file_name) |
1121 { | 1380 { |
1139 struct opt_pass *pass = (struct opt_pass *) data; | 1398 struct opt_pass *pass = (struct opt_pass *) data; |
1140 cfun->curr_properties = (cfun->curr_properties | pass->properties_provided) | 1399 cfun->curr_properties = (cfun->curr_properties | pass->properties_provided) |
1141 & ~pass->properties_destroyed; | 1400 & ~pass->properties_destroyed; |
1142 } | 1401 } |
1143 | 1402 |
1144 /* Schedule IPA transform pass DATA for CFUN. */ | |
1145 | |
1146 static void | |
1147 add_ipa_transform_pass (void *data) | |
1148 { | |
1149 struct ipa_opt_pass *ipa_pass = (struct ipa_opt_pass *) data; | |
1150 VEC_safe_push (ipa_opt_pass, heap, cfun->ipa_transforms_to_apply, ipa_pass); | |
1151 } | |
1152 | |
1153 /* Execute summary generation for all of the passes in IPA_PASS. */ | 1403 /* Execute summary generation for all of the passes in IPA_PASS. */ |
1154 | 1404 |
1155 static void | 1405 void |
1156 execute_ipa_summary_passes (struct ipa_opt_pass *ipa_pass) | 1406 execute_ipa_summary_passes (struct ipa_opt_pass_d *ipa_pass) |
1157 { | 1407 { |
1158 while (ipa_pass) | 1408 while (ipa_pass) |
1159 { | 1409 { |
1160 struct opt_pass *pass = &ipa_pass->pass; | 1410 struct opt_pass *pass = &ipa_pass->pass; |
1161 | 1411 |
1162 /* Execute all of the IPA_PASSes in the list. */ | 1412 /* Execute all of the IPA_PASSes in the list. */ |
1163 if (ipa_pass->pass.type == IPA_PASS | 1413 if (ipa_pass->pass.type == IPA_PASS |
1164 && (!pass->gate || pass->gate ())) | 1414 && (!pass->gate || pass->gate ()) |
1415 && ipa_pass->generate_summary) | |
1165 { | 1416 { |
1166 pass_init_dump_file (pass); | 1417 pass_init_dump_file (pass); |
1418 | |
1419 /* If a timevar is present, start it. */ | |
1420 if (pass->tv_id) | |
1421 timevar_push (pass->tv_id); | |
1422 | |
1167 ipa_pass->generate_summary (); | 1423 ipa_pass->generate_summary (); |
1424 | |
1425 /* Stop timevar. */ | |
1426 if (pass->tv_id) | |
1427 timevar_pop (pass->tv_id); | |
1428 | |
1168 pass_fini_dump_file (pass); | 1429 pass_fini_dump_file (pass); |
1169 } | 1430 } |
1170 ipa_pass = (struct ipa_opt_pass *)ipa_pass->pass.next; | 1431 ipa_pass = (struct ipa_opt_pass_d *)ipa_pass->pass.next; |
1171 } | 1432 } |
1172 } | 1433 } |
1173 | 1434 |
1174 /* Execute IPA_PASS function transform on NODE. */ | 1435 /* Execute IPA_PASS function transform on NODE. */ |
1175 | 1436 |
1176 static void | 1437 static void |
1177 execute_one_ipa_transform_pass (struct cgraph_node *node, | 1438 execute_one_ipa_transform_pass (struct cgraph_node *node, |
1178 struct ipa_opt_pass *ipa_pass) | 1439 struct ipa_opt_pass_d *ipa_pass) |
1179 { | 1440 { |
1180 struct opt_pass *pass = &ipa_pass->pass; | 1441 struct opt_pass *pass = &ipa_pass->pass; |
1181 unsigned int todo_after = 0; | 1442 unsigned int todo_after = 0; |
1182 | 1443 |
1183 current_pass = pass; | 1444 current_pass = pass; |
1192 | 1453 |
1193 /* Run pre-pass verification. */ | 1454 /* Run pre-pass verification. */ |
1194 execute_todo (ipa_pass->function_transform_todo_flags_start); | 1455 execute_todo (ipa_pass->function_transform_todo_flags_start); |
1195 | 1456 |
1196 /* If a timevar is present, start it. */ | 1457 /* If a timevar is present, start it. */ |
1197 if (pass->tv_id) | 1458 if (pass->tv_id != TV_NONE) |
1198 timevar_push (pass->tv_id); | 1459 timevar_push (pass->tv_id); |
1199 | 1460 |
1200 /* Do it! */ | 1461 /* Do it! */ |
1201 todo_after = ipa_pass->function_transform (node); | 1462 todo_after = ipa_pass->function_transform (node); |
1202 | 1463 |
1203 /* Stop timevar. */ | 1464 /* Stop timevar. */ |
1204 if (pass->tv_id) | 1465 if (pass->tv_id != TV_NONE) |
1205 timevar_pop (pass->tv_id); | 1466 timevar_pop (pass->tv_id); |
1206 | 1467 |
1207 /* Run post-pass cleanup and verification. */ | 1468 /* Run post-pass cleanup and verification. */ |
1208 execute_todo (todo_after); | 1469 execute_todo (todo_after); |
1209 verify_interpass_invariants (); | 1470 verify_interpass_invariants (); |
1211 pass_fini_dump_file (pass); | 1472 pass_fini_dump_file (pass); |
1212 | 1473 |
1213 current_pass = NULL; | 1474 current_pass = NULL; |
1214 } | 1475 } |
1215 | 1476 |
1216 static bool | 1477 /* For the current function, execute all ipa transforms. */ |
1478 | |
1479 void | |
1480 execute_all_ipa_transforms (void) | |
1481 { | |
1482 struct cgraph_node *node; | |
1483 if (!cfun) | |
1484 return; | |
1485 node = cgraph_node (current_function_decl); | |
1486 if (node->ipa_transforms_to_apply) | |
1487 { | |
1488 unsigned int i; | |
1489 | |
1490 for (i = 0; i < VEC_length (ipa_opt_pass, node->ipa_transforms_to_apply); | |
1491 i++) | |
1492 execute_one_ipa_transform_pass (node, | |
1493 VEC_index (ipa_opt_pass, | |
1494 node->ipa_transforms_to_apply, | |
1495 i)); | |
1496 VEC_free (ipa_opt_pass, heap, node->ipa_transforms_to_apply); | |
1497 node->ipa_transforms_to_apply = NULL; | |
1498 } | |
1499 } | |
1500 | |
1501 /* Execute PASS. */ | |
1502 | |
1503 bool | |
1217 execute_one_pass (struct opt_pass *pass) | 1504 execute_one_pass (struct opt_pass *pass) |
1218 { | 1505 { |
1219 bool initializing_dump; | 1506 bool initializing_dump; |
1220 unsigned int todo_after = 0; | 1507 unsigned int todo_after = 0; |
1508 | |
1509 bool gate_status; | |
1221 | 1510 |
1222 /* IPA passes are executed on whole program, so cfun should be NULL. | 1511 /* IPA passes are executed on whole program, so cfun should be NULL. |
1223 Other passes need function context set. */ | 1512 Other passes need function context set. */ |
1224 if (pass->type == SIMPLE_IPA_PASS || pass->type == IPA_PASS) | 1513 if (pass->type == SIMPLE_IPA_PASS || pass->type == IPA_PASS) |
1225 gcc_assert (!cfun && !current_function_decl); | 1514 gcc_assert (!cfun && !current_function_decl); |
1226 else | 1515 else |
1227 gcc_assert (cfun && current_function_decl); | 1516 gcc_assert (cfun && current_function_decl); |
1228 | 1517 |
1229 if (cfun && cfun->ipa_transforms_to_apply) | |
1230 { | |
1231 unsigned int i; | |
1232 struct cgraph_node *node = cgraph_node (current_function_decl); | |
1233 | |
1234 for (i = 0; i < VEC_length (ipa_opt_pass, cfun->ipa_transforms_to_apply); | |
1235 i++) | |
1236 execute_one_ipa_transform_pass (node, | |
1237 VEC_index (ipa_opt_pass, | |
1238 cfun->ipa_transforms_to_apply, | |
1239 i)); | |
1240 VEC_free (ipa_opt_pass, heap, cfun->ipa_transforms_to_apply); | |
1241 cfun->ipa_transforms_to_apply = NULL; | |
1242 } | |
1243 | |
1244 current_pass = pass; | 1518 current_pass = pass; |
1245 | 1519 |
1246 /* See if we're supposed to run this pass. */ | 1520 /* Check whether gate check should be avoided. |
1247 if (pass->gate && !pass->gate ()) | 1521 User controls the value of the gate through the parameter "gate_status". */ |
1248 return false; | 1522 gate_status = (pass->gate == NULL) ? true : pass->gate(); |
1523 | |
1524 /* Override gate with plugin. */ | |
1525 invoke_plugin_callbacks (PLUGIN_OVERRIDE_GATE, &gate_status); | |
1526 | |
1527 if (!gate_status) | |
1528 { | |
1529 current_pass = NULL; | |
1530 return false; | |
1531 } | |
1532 | |
1533 /* Pass execution event trigger: useful to identify passes being | |
1534 executed. */ | |
1535 invoke_plugin_callbacks (PLUGIN_PASS_EXECUTION, pass); | |
1249 | 1536 |
1250 if (!quiet_flag && !cfun) | 1537 if (!quiet_flag && !cfun) |
1251 fprintf (stderr, " <%s>", pass->name ? pass->name : ""); | 1538 fprintf (stderr, " <%s>", pass->name ? pass->name : ""); |
1252 | |
1253 if (pass->todo_flags_start & TODO_set_props) | |
1254 cfun->curr_properties = pass->properties_required; | |
1255 | 1539 |
1256 /* Note that the folders should only create gimple expressions. | 1540 /* Note that the folders should only create gimple expressions. |
1257 This is a hack until the new folder is ready. */ | 1541 This is a hack until the new folder is ready. */ |
1258 in_gimple_form = (cfun && (cfun->curr_properties & PROP_trees)) != 0; | 1542 in_gimple_form = (cfun && (cfun->curr_properties & PROP_trees)) != 0; |
1543 | |
1544 initializing_dump = pass_init_dump_file (pass); | |
1259 | 1545 |
1260 /* Run pre-pass verification. */ | 1546 /* Run pre-pass verification. */ |
1261 execute_todo (pass->todo_flags_start); | 1547 execute_todo (pass->todo_flags_start); |
1262 | 1548 |
1263 #ifdef ENABLE_CHECKING | 1549 #ifdef ENABLE_CHECKING |
1264 do_per_function (verify_curr_properties, | 1550 do_per_function (verify_curr_properties, |
1265 (void *)(size_t)pass->properties_required); | 1551 (void *)(size_t)pass->properties_required); |
1266 #endif | 1552 #endif |
1267 | 1553 |
1268 initializing_dump = pass_init_dump_file (pass); | |
1269 | |
1270 /* If a timevar is present, start it. */ | 1554 /* If a timevar is present, start it. */ |
1271 if (pass->tv_id) | 1555 if (pass->tv_id != TV_NONE) |
1272 timevar_push (pass->tv_id); | 1556 timevar_push (pass->tv_id); |
1273 | 1557 |
1274 /* Do it! */ | 1558 /* Do it! */ |
1275 if (pass->execute) | 1559 if (pass->execute) |
1276 { | 1560 { |
1277 todo_after = pass->execute (); | 1561 todo_after = pass->execute (); |
1278 do_per_function (clear_last_verified, NULL); | 1562 do_per_function (clear_last_verified, NULL); |
1279 } | 1563 } |
1280 | 1564 |
1281 /* Stop timevar. */ | 1565 /* Stop timevar. */ |
1282 if (pass->tv_id) | 1566 if (pass->tv_id != TV_NONE) |
1283 timevar_pop (pass->tv_id); | 1567 timevar_pop (pass->tv_id); |
1284 | 1568 |
1285 do_per_function (update_properties_after_pass, pass); | 1569 do_per_function (update_properties_after_pass, pass); |
1286 | 1570 |
1287 if (initializing_dump | 1571 if (initializing_dump |
1298 | 1582 |
1299 /* Run post-pass cleanup and verification. */ | 1583 /* Run post-pass cleanup and verification. */ |
1300 execute_todo (todo_after | pass->todo_flags_finish); | 1584 execute_todo (todo_after | pass->todo_flags_finish); |
1301 verify_interpass_invariants (); | 1585 verify_interpass_invariants (); |
1302 if (pass->type == IPA_PASS) | 1586 if (pass->type == IPA_PASS) |
1303 do_per_function (add_ipa_transform_pass, pass); | 1587 { |
1588 struct cgraph_node *node; | |
1589 for (node = cgraph_nodes; node; node = node->next) | |
1590 if (node->analyzed) | |
1591 VEC_safe_push (ipa_opt_pass, heap, node->ipa_transforms_to_apply, | |
1592 (struct ipa_opt_pass_d *)pass); | |
1593 } | |
1304 | 1594 |
1305 if (!current_function_decl) | 1595 if (!current_function_decl) |
1306 cgraph_process_new_functions (); | 1596 cgraph_process_new_functions (); |
1307 | 1597 |
1308 pass_fini_dump_file (pass); | 1598 pass_fini_dump_file (pass); |
1329 } | 1619 } |
1330 while (pass); | 1620 while (pass); |
1331 } | 1621 } |
1332 | 1622 |
1333 /* Same as execute_pass_list but assume that subpasses of IPA passes | 1623 /* Same as execute_pass_list but assume that subpasses of IPA passes |
1624 are local passes. If SET is not NULL, write out summaries of only | |
1625 those node in SET. */ | |
1626 | |
1627 static void | |
1628 ipa_write_summaries_2 (struct opt_pass *pass, cgraph_node_set set, | |
1629 struct lto_out_decl_state *state) | |
1630 { | |
1631 while (pass) | |
1632 { | |
1633 struct ipa_opt_pass_d *ipa_pass = (struct ipa_opt_pass_d *)pass; | |
1634 gcc_assert (!current_function_decl); | |
1635 gcc_assert (!cfun); | |
1636 gcc_assert (pass->type == SIMPLE_IPA_PASS || pass->type == IPA_PASS); | |
1637 if (pass->type == IPA_PASS | |
1638 && ipa_pass->write_summary | |
1639 && (!pass->gate || pass->gate ())) | |
1640 { | |
1641 /* If a timevar is present, start it. */ | |
1642 if (pass->tv_id) | |
1643 timevar_push (pass->tv_id); | |
1644 | |
1645 ipa_pass->write_summary (set); | |
1646 | |
1647 /* If a timevar is present, start it. */ | |
1648 if (pass->tv_id) | |
1649 timevar_pop (pass->tv_id); | |
1650 } | |
1651 | |
1652 if (pass->sub && pass->sub->type != GIMPLE_PASS) | |
1653 ipa_write_summaries_2 (pass->sub, set, state); | |
1654 | |
1655 pass = pass->next; | |
1656 } | |
1657 } | |
1658 | |
1659 /* Helper function of ipa_write_summaries. Creates and destroys the | |
1660 decl state and calls ipa_write_summaries_2 for all passes that have | |
1661 summaries. SET is the set of nodes to be written. */ | |
1662 | |
1663 static void | |
1664 ipa_write_summaries_1 (cgraph_node_set set) | |
1665 { | |
1666 struct lto_out_decl_state *state = lto_new_out_decl_state (); | |
1667 lto_push_out_decl_state (state); | |
1668 | |
1669 if (!flag_wpa) | |
1670 ipa_write_summaries_2 (all_regular_ipa_passes, set, state); | |
1671 ipa_write_summaries_2 (all_lto_gen_passes, set, state); | |
1672 | |
1673 gcc_assert (lto_get_out_decl_state () == state); | |
1674 lto_pop_out_decl_state (); | |
1675 lto_delete_out_decl_state (state); | |
1676 } | |
1677 | |
1678 /* Write out summaries for all the nodes in the callgraph. */ | |
1679 | |
1680 void | |
1681 ipa_write_summaries (void) | |
1682 { | |
1683 cgraph_node_set set; | |
1684 struct cgraph_node **order; | |
1685 int i, order_pos; | |
1686 | |
1687 if (!flag_generate_lto || errorcount || sorrycount) | |
1688 return; | |
1689 | |
1690 lto_new_extern_inline_states (); | |
1691 set = cgraph_node_set_new (); | |
1692 | |
1693 /* Create the callgraph set in the same order used in | |
1694 cgraph_expand_all_functions. This mostly facilitates debugging, | |
1695 since it causes the gimple file to be processed in the same order | |
1696 as the source code. */ | |
1697 order = XCNEWVEC (struct cgraph_node *, cgraph_n_nodes); | |
1698 order_pos = cgraph_postorder (order); | |
1699 gcc_assert (order_pos == cgraph_n_nodes); | |
1700 | |
1701 for (i = order_pos - 1; i >= 0; i--) | |
1702 { | |
1703 struct cgraph_node *node = order[i]; | |
1704 | |
1705 if (node->analyzed) | |
1706 { | |
1707 /* When streaming out references to statements as part of some IPA | |
1708 pass summary, the statements need to have uids assigned and the | |
1709 following does that for all the IPA passes here. Naturally, this | |
1710 ordering then matches the one IPA-passes get in their stmt_fixup | |
1711 hooks. */ | |
1712 | |
1713 push_cfun (DECL_STRUCT_FUNCTION (node->decl)); | |
1714 renumber_gimple_stmt_uids (); | |
1715 pop_cfun (); | |
1716 } | |
1717 cgraph_node_set_add (set, node); | |
1718 } | |
1719 | |
1720 ipa_write_summaries_1 (set); | |
1721 lto_delete_extern_inline_states (); | |
1722 | |
1723 free (order); | |
1724 ggc_free (set); | |
1725 } | |
1726 | |
1727 | |
1728 /* Write all the summaries for the cgraph nodes in SET. If SET is | |
1729 NULL, write out all summaries of all nodes. */ | |
1730 | |
1731 void | |
1732 ipa_write_summaries_of_cgraph_node_set (cgraph_node_set set) | |
1733 { | |
1734 if (flag_generate_lto && !(errorcount || sorrycount)) | |
1735 ipa_write_summaries_1 (set); | |
1736 } | |
1737 | |
1738 /* Same as execute_pass_list but assume that subpasses of IPA passes | |
1739 are local passes. */ | |
1740 | |
1741 static void | |
1742 ipa_read_summaries_1 (struct opt_pass *pass) | |
1743 { | |
1744 while (pass) | |
1745 { | |
1746 struct ipa_opt_pass_d *ipa_pass = (struct ipa_opt_pass_d *) pass; | |
1747 | |
1748 gcc_assert (!current_function_decl); | |
1749 gcc_assert (!cfun); | |
1750 gcc_assert (pass->type == SIMPLE_IPA_PASS || pass->type == IPA_PASS); | |
1751 | |
1752 if (pass->gate == NULL || pass->gate ()) | |
1753 { | |
1754 if (pass->type == IPA_PASS && ipa_pass->read_summary) | |
1755 { | |
1756 /* If a timevar is present, start it. */ | |
1757 if (pass->tv_id) | |
1758 timevar_push (pass->tv_id); | |
1759 | |
1760 ipa_pass->read_summary (); | |
1761 | |
1762 /* Stop timevar. */ | |
1763 if (pass->tv_id) | |
1764 timevar_pop (pass->tv_id); | |
1765 } | |
1766 | |
1767 if (pass->sub && pass->sub->type != GIMPLE_PASS) | |
1768 ipa_read_summaries_1 (pass->sub); | |
1769 } | |
1770 pass = pass->next; | |
1771 } | |
1772 } | |
1773 | |
1774 | |
1775 /* Read all the summaries for all_regular_ipa_passes and all_lto_gen_passes. */ | |
1776 | |
1777 void | |
1778 ipa_read_summaries (void) | |
1779 { | |
1780 if (!flag_ltrans) | |
1781 ipa_read_summaries_1 (all_regular_ipa_passes); | |
1782 ipa_read_summaries_1 (all_lto_gen_passes); | |
1783 } | |
1784 | |
1785 /* Same as execute_pass_list but assume that subpasses of IPA passes | |
1334 are local passes. */ | 1786 are local passes. */ |
1335 void | 1787 void |
1336 execute_ipa_pass_list (struct opt_pass *pass) | 1788 execute_ipa_pass_list (struct opt_pass *pass) |
1337 { | 1789 { |
1338 bool summaries_generated = false; | |
1339 do | 1790 do |
1340 { | 1791 { |
1341 gcc_assert (!current_function_decl); | 1792 gcc_assert (!current_function_decl); |
1342 gcc_assert (!cfun); | 1793 gcc_assert (!cfun); |
1343 gcc_assert (pass->type == SIMPLE_IPA_PASS || pass->type == IPA_PASS); | 1794 gcc_assert (pass->type == SIMPLE_IPA_PASS || pass->type == IPA_PASS); |
1344 if (pass->type == IPA_PASS && (!pass->gate || pass->gate ())) | |
1345 { | |
1346 if (!summaries_generated) | |
1347 { | |
1348 if (!quiet_flag && !cfun) | |
1349 fprintf (stderr, " <summary generate>"); | |
1350 execute_ipa_summary_passes ((struct ipa_opt_pass *) pass); | |
1351 } | |
1352 summaries_generated = true; | |
1353 } | |
1354 if (execute_one_pass (pass) && pass->sub) | 1795 if (execute_one_pass (pass) && pass->sub) |
1355 { | 1796 { |
1356 if (pass->sub->type == GIMPLE_PASS) | 1797 if (pass->sub->type == GIMPLE_PASS) |
1357 do_per_function_toporder ((void (*)(void *))execute_pass_list, | 1798 { |
1358 pass->sub); | 1799 invoke_plugin_callbacks (PLUGIN_EARLY_GIMPLE_PASSES_START, NULL); |
1800 do_per_function_toporder ((void (*)(void *))execute_pass_list, | |
1801 pass->sub); | |
1802 invoke_plugin_callbacks (PLUGIN_EARLY_GIMPLE_PASSES_END, NULL); | |
1803 } | |
1359 else if (pass->sub->type == SIMPLE_IPA_PASS | 1804 else if (pass->sub->type == SIMPLE_IPA_PASS |
1360 || pass->sub->type == IPA_PASS) | 1805 || pass->sub->type == IPA_PASS) |
1361 execute_ipa_pass_list (pass->sub); | 1806 execute_ipa_pass_list (pass->sub); |
1362 else | 1807 else |
1363 gcc_unreachable (); | 1808 gcc_unreachable (); |
1364 } | 1809 } |
1365 if (!current_function_decl) | 1810 gcc_assert (!current_function_decl); |
1366 cgraph_process_new_functions (); | 1811 cgraph_process_new_functions (); |
1367 pass = pass->next; | 1812 pass = pass->next; |
1368 } | 1813 } |
1369 while (pass); | 1814 while (pass); |
1370 } | 1815 } |
1371 | 1816 |
1817 /* Execute stmt fixup hooks of all passes in PASS for NODE and STMTS. */ | |
1818 | |
1819 static void | |
1820 execute_ipa_stmt_fixups (struct opt_pass *pass, | |
1821 struct cgraph_node *node, gimple *stmts) | |
1822 { | |
1823 while (pass) | |
1824 { | |
1825 /* Execute all of the IPA_PASSes in the list. */ | |
1826 if (pass->type == IPA_PASS | |
1827 && (!pass->gate || pass->gate ())) | |
1828 { | |
1829 struct ipa_opt_pass_d *ipa_pass = (struct ipa_opt_pass_d *) pass; | |
1830 | |
1831 if (ipa_pass->stmt_fixup) | |
1832 { | |
1833 pass_init_dump_file (pass); | |
1834 /* If a timevar is present, start it. */ | |
1835 if (pass->tv_id) | |
1836 timevar_push (pass->tv_id); | |
1837 | |
1838 ipa_pass->stmt_fixup (node, stmts); | |
1839 | |
1840 /* Stop timevar. */ | |
1841 if (pass->tv_id) | |
1842 timevar_pop (pass->tv_id); | |
1843 pass_fini_dump_file (pass); | |
1844 } | |
1845 if (pass->sub) | |
1846 execute_ipa_stmt_fixups (pass->sub, node, stmts); | |
1847 } | |
1848 pass = pass->next; | |
1849 } | |
1850 } | |
1851 | |
1852 /* Execute stmt fixup hooks of all IPA passes for NODE and STMTS. */ | |
1853 | |
1854 void | |
1855 execute_all_ipa_stmt_fixups (struct cgraph_node *node, gimple *stmts) | |
1856 { | |
1857 execute_ipa_stmt_fixups (all_regular_ipa_passes, node, stmts); | |
1858 } | |
1859 | |
1860 | |
1861 extern void debug_properties (unsigned int); | |
1862 extern void dump_properties (FILE *, unsigned int); | |
1863 | |
1864 void | |
1865 dump_properties (FILE *dump, unsigned int props) | |
1866 { | |
1867 fprintf (dump, "Properties:\n"); | |
1868 if (props & PROP_gimple_any) | |
1869 fprintf (dump, "PROP_gimple_any\n"); | |
1870 if (props & PROP_gimple_lcf) | |
1871 fprintf (dump, "PROP_gimple_lcf\n"); | |
1872 if (props & PROP_gimple_leh) | |
1873 fprintf (dump, "PROP_gimple_leh\n"); | |
1874 if (props & PROP_cfg) | |
1875 fprintf (dump, "PROP_cfg\n"); | |
1876 if (props & PROP_referenced_vars) | |
1877 fprintf (dump, "PROP_referenced_vars\n"); | |
1878 if (props & PROP_ssa) | |
1879 fprintf (dump, "PROP_ssa\n"); | |
1880 if (props & PROP_no_crit_edges) | |
1881 fprintf (dump, "PROP_no_crit_edges\n"); | |
1882 if (props & PROP_rtl) | |
1883 fprintf (dump, "PROP_rtl\n"); | |
1884 if (props & PROP_gimple_lomp) | |
1885 fprintf (dump, "PROP_gimple_lomp\n"); | |
1886 } | |
1887 | |
1888 void | |
1889 debug_properties (unsigned int props) | |
1890 { | |
1891 dump_properties (stderr, props); | |
1892 } | |
1893 | |
1894 /* Called by local passes to see if function is called by already processed nodes. | |
1895 Because we process nodes in topological order, this means that function is | |
1896 in recursive cycle or we introduced new direct calls. */ | |
1897 bool | |
1898 function_called_by_processed_nodes_p (void) | |
1899 { | |
1900 struct cgraph_edge *e; | |
1901 for (e = cgraph_node (current_function_decl)->callers; e; e = e->next_caller) | |
1902 { | |
1903 if (e->caller->decl == current_function_decl) | |
1904 continue; | |
1905 if (!e->caller->analyzed) | |
1906 continue; | |
1907 if (TREE_ASM_WRITTEN (e->caller->decl)) | |
1908 continue; | |
1909 if (!e->caller->process && !e->caller->global.inlined_to) | |
1910 break; | |
1911 } | |
1912 if (dump_file && e) | |
1913 { | |
1914 fprintf (dump_file, "Already processed call to:\n"); | |
1915 dump_cgraph_node (dump_file, e->caller); | |
1916 } | |
1917 return e != NULL; | |
1918 } | |
1919 | |
1372 #include "gt-passes.h" | 1920 #include "gt-passes.h" |