Mercurial > hg > CbC > CbC_gcc
comparison gcc/passes.c @ 63:b7f97abdc517 gcc-4.6-20100522
update gcc from gcc-4.5.0 to gcc-4.6
author | ryoma <e075725@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 24 May 2010 12:47:05 +0900 |
parents | 77e2b8dfacca |
children | f6334be47118 |
comparison
equal
deleted
inserted
replaced
56:3c8a44c06a95 | 63:b7f97abdc517 |
---|---|
1 /* Top level of GCC compilers (cc1, cc1plus, etc.) | 1 /* Top level of GCC compilers (cc1, cc1plus, etc.) |
2 Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, | 2 Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, |
3 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 | 3 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 |
4 Free Software Foundation, Inc. | 4 Free Software Foundation, Inc. |
5 | 5 |
6 This file is part of GCC. | 6 This file is part of GCC. |
7 | 7 |
8 GCC is free software; you can redistribute it and/or modify it under | 8 GCC is free software; you can redistribute it and/or modify it under |
23 It parses command args, opens files, invokes the various passes | 23 It parses command args, opens files, invokes the various passes |
24 in the proper order, and counts the time used by each. | 24 in the proper order, and counts the time used by each. |
25 Error messages and low-level interface to malloc also handled here. */ | 25 Error messages and low-level interface to malloc also handled here. */ |
26 | 26 |
27 #include "config.h" | 27 #include "config.h" |
28 #undef FLOAT /* This is for hpux. They should change hpux. */ | |
29 #undef FFS /* Some systems define this in param.h. */ | |
30 #include "system.h" | 28 #include "system.h" |
31 #include "coretypes.h" | 29 #include "coretypes.h" |
32 #include "tm.h" | 30 #include "tm.h" |
33 #include <signal.h> | 31 #include <signal.h> |
34 | 32 |
65 #include "diagnostic.h" | 63 #include "diagnostic.h" |
66 #include "params.h" | 64 #include "params.h" |
67 #include "reload.h" | 65 #include "reload.h" |
68 #include "dwarf2asm.h" | 66 #include "dwarf2asm.h" |
69 #include "integrate.h" | 67 #include "integrate.h" |
70 #include "real.h" | |
71 #include "debug.h" | 68 #include "debug.h" |
72 #include "target.h" | 69 #include "target.h" |
73 #include "langhooks.h" | 70 #include "langhooks.h" |
74 #include "cfglayout.h" | 71 #include "cfglayout.h" |
75 #include "cfgloop.h" | 72 #include "cfgloop.h" |
189 if ((at_end | 186 if ((at_end |
190 || !DECL_DEFER_OUTPUT (decl) | 187 || !DECL_DEFER_OUTPUT (decl) |
191 || DECL_INITIAL (decl)) | 188 || DECL_INITIAL (decl)) |
192 && !DECL_EXTERNAL (decl)) | 189 && !DECL_EXTERNAL (decl)) |
193 { | 190 { |
194 if (TREE_CODE (decl) != FUNCTION_DECL) | 191 /* When reading LTO unit, we also read varpool, so do not |
192 rebuild it. */ | |
193 if (in_lto_p && !at_end) | |
194 ; | |
195 else if (TREE_CODE (decl) != FUNCTION_DECL) | |
195 varpool_finalize_decl (decl); | 196 varpool_finalize_decl (decl); |
196 else | 197 else |
197 assemble_variable (decl, top_level, at_end, 0); | 198 assemble_variable (decl, top_level, at_end, 0); |
198 } | 199 } |
199 | 200 |
216 debug_hooks->type_decl (decl, !top_level); | 217 debug_hooks->type_decl (decl, !top_level); |
217 timevar_pop (TV_SYMOUT); | 218 timevar_pop (TV_SYMOUT); |
218 } | 219 } |
219 | 220 |
220 /* Let cgraph know about the existence of variables. */ | 221 /* Let cgraph know about the existence of variables. */ |
221 if (TREE_CODE (decl) == VAR_DECL && !DECL_EXTERNAL (decl)) | 222 if (in_lto_p && !at_end) |
223 ; | |
224 else if (TREE_CODE (decl) == VAR_DECL && !DECL_EXTERNAL (decl)) | |
222 varpool_node (decl); | 225 varpool_node (decl); |
223 } | 226 } |
224 | 227 |
225 /* Called after finishing a record, union or enumeral type. */ | 228 /* Called after finishing a record, union or enumeral type. */ |
226 | 229 |
630 the pass */ | 633 the pass */ |
631 | 634 |
632 void | 635 void |
633 register_pass (struct register_pass_info *pass_info) | 636 register_pass (struct register_pass_info *pass_info) |
634 { | 637 { |
638 bool all_instances, success; | |
639 | |
635 /* The checks below could fail in buggy plugins. Existing GCC | 640 /* The checks below could fail in buggy plugins. Existing GCC |
636 passes should never fail these checks, so we mention plugin in | 641 passes should never fail these checks, so we mention plugin in |
637 the messages. */ | 642 the messages. */ |
638 if (!pass_info->pass) | 643 if (!pass_info->pass) |
639 fatal_error ("plugin cannot register a missing pass"); | 644 fatal_error ("plugin cannot register a missing pass"); |
645 fatal_error | 650 fatal_error |
646 ("plugin cannot register pass %qs without reference pass name", | 651 ("plugin cannot register pass %qs without reference pass name", |
647 pass_info->pass->name); | 652 pass_info->pass->name); |
648 | 653 |
649 /* Try to insert the new pass to the pass lists. We need to check | 654 /* 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 | 655 all five lists as the reference pass could be in one (or all) of |
651 them. */ | 656 them. */ |
652 if (!position_pass (pass_info, &all_lowering_passes) | 657 all_instances = pass_info->ref_pass_instance_number == 0; |
653 && !position_pass (pass_info, &all_small_ipa_passes) | 658 success = position_pass (pass_info, &all_lowering_passes); |
654 && !position_pass (pass_info, &all_regular_ipa_passes) | 659 if (!success || all_instances) |
655 && !position_pass (pass_info, &all_lto_gen_passes) | 660 success |= position_pass (pass_info, &all_small_ipa_passes); |
656 && !position_pass (pass_info, &all_passes)) | 661 if (!success || all_instances) |
662 success |= position_pass (pass_info, &all_regular_ipa_passes); | |
663 if (!success || all_instances) | |
664 success |= position_pass (pass_info, &all_lto_gen_passes); | |
665 if (!success || all_instances) | |
666 success |= position_pass (pass_info, &all_passes); | |
667 if (!success) | |
657 fatal_error | 668 fatal_error |
658 ("pass %qs not found but is referenced by new pass %qs", | 669 ("pass %qs not found but is referenced by new pass %qs", |
659 pass_info->reference_pass_name, pass_info->pass->name); | 670 pass_info->reference_pass_name, pass_info->pass->name); |
660 else | 671 |
661 { | 672 /* OK, we have successfully inserted the new pass. We need to register |
662 /* OK, we have successfully inserted the new pass. We need to register | 673 the dump files for the newly added pass and its duplicates (if any). |
663 the dump files for the newly added pass and its duplicates (if any). | 674 Because the registration of plugin/backend passes happens after the |
664 Because the registration of plugin/backend passes happens after the | 675 command-line options are parsed, the options that specify single |
665 command-line options are parsed, the options that specify single | 676 pass dumping (e.g. -fdump-tree-PASSNAME) cannot be used for new |
666 pass dumping (e.g. -fdump-tree-PASSNAME) cannot be used for new | 677 passes. Therefore we currently can only enable dumping of |
667 passes. Therefore we currently can only enable dumping of | 678 new passes when the 'dump-all' flags (e.g. -fdump-tree-all) |
668 new passes when the 'dump-all' flags (e.g. -fdump-tree-all) | 679 are specified. While doing so, we also delete the pass_list_node |
669 are specified. While doing so, we also delete the pass_list_node | 680 objects created during pass positioning. */ |
670 objects created during pass positioning. */ | 681 while (added_pass_nodes) |
671 while (added_pass_nodes) | 682 { |
672 { | 683 struct pass_list_node *next_node = added_pass_nodes->next; |
673 struct pass_list_node *next_node = added_pass_nodes->next; | 684 enum tree_dump_index tdi; |
674 enum tree_dump_index tdi; | 685 register_one_dump_file (added_pass_nodes->pass); |
675 register_one_dump_file (added_pass_nodes->pass); | 686 if (added_pass_nodes->pass->type == SIMPLE_IPA_PASS |
676 if (added_pass_nodes->pass->type == SIMPLE_IPA_PASS | 687 || added_pass_nodes->pass->type == IPA_PASS) |
677 || added_pass_nodes->pass->type == IPA_PASS) | 688 tdi = TDI_ipa_all; |
678 tdi = TDI_ipa_all; | 689 else if (added_pass_nodes->pass->type == GIMPLE_PASS) |
679 else if (added_pass_nodes->pass->type == GIMPLE_PASS) | 690 tdi = TDI_tree_all; |
680 tdi = TDI_tree_all; | 691 else |
681 else | 692 tdi = TDI_rtl_all; |
682 tdi = TDI_rtl_all; | 693 /* Check if dump-all flag is specified. */ |
683 /* Check if dump-all flag is specified. */ | 694 if (get_dump_file_info (tdi)->state) |
684 if (get_dump_file_info (tdi)->state) | 695 get_dump_file_info (added_pass_nodes->pass->static_pass_number) |
685 get_dump_file_info (added_pass_nodes->pass->static_pass_number) | 696 ->state = get_dump_file_info (tdi)->state; |
686 ->state = get_dump_file_info (tdi)->state; | 697 XDELETE (added_pass_nodes); |
687 XDELETE (added_pass_nodes); | 698 added_pass_nodes = next_node; |
688 added_pass_nodes = next_node; | |
689 } | |
690 } | 699 } |
691 } | 700 } |
692 | 701 |
693 /* Construct the pass tree. The sequencing of passes is driven by | 702 /* Construct the pass tree. The sequencing of passes is driven by |
694 the cgraph routines: | 703 the cgraph routines: |
726 NEXT_PASS (pass_lower_omp); | 735 NEXT_PASS (pass_lower_omp); |
727 NEXT_PASS (pass_lower_cf); | 736 NEXT_PASS (pass_lower_cf); |
728 NEXT_PASS (pass_refactor_eh); | 737 NEXT_PASS (pass_refactor_eh); |
729 NEXT_PASS (pass_lower_eh); | 738 NEXT_PASS (pass_lower_eh); |
730 NEXT_PASS (pass_build_cfg); | 739 NEXT_PASS (pass_build_cfg); |
731 NEXT_PASS (pass_lower_complex_O0); | |
732 NEXT_PASS (pass_lower_vector); | 740 NEXT_PASS (pass_lower_vector); |
733 NEXT_PASS (pass_warn_function_return); | 741 NEXT_PASS (pass_warn_function_return); |
734 NEXT_PASS (pass_build_cgraph_edges); | 742 NEXT_PASS (pass_build_cgraph_edges); |
735 NEXT_PASS (pass_inline_parameters); | 743 NEXT_PASS (pass_inline_parameters); |
736 *p = NULL; | 744 *p = NULL; |
737 | 745 |
738 /* Interprocedural optimization passes. */ | 746 /* Interprocedural optimization passes. */ |
739 p = &all_small_ipa_passes; | 747 p = &all_small_ipa_passes; |
748 NEXT_PASS (pass_ipa_free_lang_data); | |
740 NEXT_PASS (pass_ipa_function_and_variable_visibility); | 749 NEXT_PASS (pass_ipa_function_and_variable_visibility); |
741 NEXT_PASS (pass_ipa_early_inline); | 750 NEXT_PASS (pass_ipa_early_inline); |
742 { | 751 { |
743 struct opt_pass **p = &pass_ipa_early_inline.pass.sub; | 752 struct opt_pass **p = &pass_ipa_early_inline.pass.sub; |
744 NEXT_PASS (pass_early_inline); | 753 NEXT_PASS (pass_early_inline); |
745 NEXT_PASS (pass_inline_parameters); | 754 NEXT_PASS (pass_inline_parameters); |
746 NEXT_PASS (pass_rebuild_cgraph_edges); | 755 NEXT_PASS (pass_rebuild_cgraph_edges); |
747 } | 756 } |
748 NEXT_PASS (pass_ipa_free_lang_data); | |
749 NEXT_PASS (pass_early_local_passes); | 757 NEXT_PASS (pass_early_local_passes); |
750 { | 758 { |
751 struct opt_pass **p = &pass_early_local_passes.pass.sub; | 759 struct opt_pass **p = &pass_early_local_passes.pass.sub; |
752 NEXT_PASS (pass_fixup_cfg); | 760 NEXT_PASS (pass_fixup_cfg); |
753 NEXT_PASS (pass_tree_profile); | 761 NEXT_PASS (pass_tree_profile); |
796 NEXT_PASS (pass_ipa_matrix_reorg); | 804 NEXT_PASS (pass_ipa_matrix_reorg); |
797 *p = NULL; | 805 *p = NULL; |
798 | 806 |
799 p = &all_regular_ipa_passes; | 807 p = &all_regular_ipa_passes; |
800 NEXT_PASS (pass_ipa_whole_program_visibility); | 808 NEXT_PASS (pass_ipa_whole_program_visibility); |
809 NEXT_PASS (pass_ipa_profile); | |
801 NEXT_PASS (pass_ipa_cp); | 810 NEXT_PASS (pass_ipa_cp); |
802 NEXT_PASS (pass_ipa_inline); | 811 NEXT_PASS (pass_ipa_inline); |
803 NEXT_PASS (pass_ipa_reference); | 812 NEXT_PASS (pass_ipa_reference); |
804 NEXT_PASS (pass_ipa_pure_const); | 813 NEXT_PASS (pass_ipa_pure_const); |
805 NEXT_PASS (pass_ipa_type_escape); | 814 NEXT_PASS (pass_ipa_type_escape); |
807 NEXT_PASS (pass_ipa_struct_reorg); | 816 NEXT_PASS (pass_ipa_struct_reorg); |
808 *p = NULL; | 817 *p = NULL; |
809 | 818 |
810 p = &all_lto_gen_passes; | 819 p = &all_lto_gen_passes; |
811 NEXT_PASS (pass_ipa_lto_gimple_out); | 820 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. */ | 821 NEXT_PASS (pass_ipa_lto_finish_out); /* This must be the last LTO pass. */ |
814 *p = NULL; | 822 *p = NULL; |
815 | 823 |
816 /* These passes are run after IPA passes on every function that is being | 824 /* These passes are run after IPA passes on every function that is being |
817 output to the assembler file. */ | 825 output to the assembler file. */ |
878 NEXT_PASS (pass_sink_code); | 886 NEXT_PASS (pass_sink_code); |
879 NEXT_PASS (pass_tree_loop); | 887 NEXT_PASS (pass_tree_loop); |
880 { | 888 { |
881 struct opt_pass **p = &pass_tree_loop.pass.sub; | 889 struct opt_pass **p = &pass_tree_loop.pass.sub; |
882 NEXT_PASS (pass_tree_loop_init); | 890 NEXT_PASS (pass_tree_loop_init); |
891 NEXT_PASS (pass_lim); | |
883 NEXT_PASS (pass_copy_prop); | 892 NEXT_PASS (pass_copy_prop); |
884 NEXT_PASS (pass_dce_loop); | 893 NEXT_PASS (pass_dce_loop); |
885 NEXT_PASS (pass_lim); | |
886 NEXT_PASS (pass_tree_unswitch); | 894 NEXT_PASS (pass_tree_unswitch); |
887 NEXT_PASS (pass_scev_cprop); | 895 NEXT_PASS (pass_scev_cprop); |
888 NEXT_PASS (pass_record_bounds); | 896 NEXT_PASS (pass_record_bounds); |
889 NEXT_PASS (pass_check_data_deps); | 897 NEXT_PASS (pass_check_data_deps); |
890 NEXT_PASS (pass_loop_distribution); | 898 NEXT_PASS (pass_loop_distribution); |
891 NEXT_PASS (pass_linear_transform); | 899 NEXT_PASS (pass_linear_transform); |
892 NEXT_PASS (pass_graphite_transforms); | 900 NEXT_PASS (pass_graphite_transforms); |
893 { | 901 { |
894 struct opt_pass **p = &pass_graphite_transforms.pass.sub; | 902 struct opt_pass **p = &pass_graphite_transforms.pass.sub; |
903 NEXT_PASS (pass_copy_prop); | |
895 NEXT_PASS (pass_dce_loop); | 904 NEXT_PASS (pass_dce_loop); |
896 NEXT_PASS (pass_lim); | 905 NEXT_PASS (pass_lim); |
897 } | 906 } |
898 NEXT_PASS (pass_iv_canon); | 907 NEXT_PASS (pass_iv_canon); |
899 NEXT_PASS (pass_if_conversion); | 908 NEXT_PASS (pass_if_conversion); |
936 NEXT_PASS (pass_late_warn_uninitialized); | 945 NEXT_PASS (pass_late_warn_uninitialized); |
937 NEXT_PASS (pass_dse); | 946 NEXT_PASS (pass_dse); |
938 NEXT_PASS (pass_forwprop); | 947 NEXT_PASS (pass_forwprop); |
939 NEXT_PASS (pass_phiopt); | 948 NEXT_PASS (pass_phiopt); |
940 NEXT_PASS (pass_fold_builtins); | 949 NEXT_PASS (pass_fold_builtins); |
950 NEXT_PASS (pass_optimize_widening_mul); | |
941 NEXT_PASS (pass_tail_calls); | 951 NEXT_PASS (pass_tail_calls); |
942 NEXT_PASS (pass_rename_ssa_copies); | 952 NEXT_PASS (pass_rename_ssa_copies); |
943 NEXT_PASS (pass_uncprop); | 953 NEXT_PASS (pass_uncprop); |
944 NEXT_PASS (pass_local_pure_const); | 954 NEXT_PASS (pass_local_pure_const); |
945 } | 955 } |
956 NEXT_PASS (pass_lower_complex_O0); | |
946 NEXT_PASS (pass_cleanup_eh); | 957 NEXT_PASS (pass_cleanup_eh); |
947 NEXT_PASS (pass_lower_resx); | 958 NEXT_PASS (pass_lower_resx); |
948 NEXT_PASS (pass_nrv); | 959 NEXT_PASS (pass_nrv); |
949 NEXT_PASS (pass_mudflap_2); | 960 NEXT_PASS (pass_mudflap_2); |
950 NEXT_PASS (pass_cleanup_cfg_post_optimizing); | 961 NEXT_PASS (pass_cleanup_cfg_post_optimizing); |
1015 { | 1026 { |
1016 struct opt_pass **p = &pass_postreload.pass.sub; | 1027 struct opt_pass **p = &pass_postreload.pass.sub; |
1017 NEXT_PASS (pass_postreload_cse); | 1028 NEXT_PASS (pass_postreload_cse); |
1018 NEXT_PASS (pass_gcse2); | 1029 NEXT_PASS (pass_gcse2); |
1019 NEXT_PASS (pass_split_after_reload); | 1030 NEXT_PASS (pass_split_after_reload); |
1031 NEXT_PASS (pass_implicit_zee); | |
1020 NEXT_PASS (pass_branch_target_load_optimize1); | 1032 NEXT_PASS (pass_branch_target_load_optimize1); |
1021 NEXT_PASS (pass_thread_prologue_and_epilogue); | 1033 NEXT_PASS (pass_thread_prologue_and_epilogue); |
1022 NEXT_PASS (pass_rtl_dse2); | 1034 NEXT_PASS (pass_rtl_dse2); |
1023 NEXT_PASS (pass_stack_adjustments); | 1035 NEXT_PASS (pass_stack_adjustments); |
1024 NEXT_PASS (pass_peephole2); | 1036 NEXT_PASS (pass_peephole2); |
1247 else | 1259 else |
1248 gcc_unreachable (); | 1260 gcc_unreachable (); |
1249 } | 1261 } |
1250 | 1262 |
1251 #if defined ENABLE_CHECKING | 1263 #if defined ENABLE_CHECKING |
1252 if (flags & TODO_verify_ssa) | 1264 if (flags & TODO_verify_ssa |
1265 || (current_loops && loops_state_satisfies_p (LOOP_CLOSED_SSA))) | |
1253 verify_ssa (true); | 1266 verify_ssa (true); |
1254 if (flags & TODO_verify_flow) | 1267 if (flags & TODO_verify_flow) |
1255 verify_flow_info (); | 1268 verify_flow_info (); |
1256 if (flags & TODO_verify_stmts) | 1269 if (flags & TODO_verify_stmts) |
1257 verify_stmts (); | 1270 verify_stmts (); |
1258 if (flags & TODO_verify_loops) | 1271 if (current_loops && loops_state_satisfies_p (LOOP_CLOSED_SSA)) |
1259 verify_loop_closed_ssa (); | 1272 verify_loop_closed_ssa (false); |
1260 if (flags & TODO_verify_rtl_sharing) | 1273 if (flags & TODO_verify_rtl_sharing) |
1261 verify_rtl_sharing (); | 1274 verify_rtl_sharing (); |
1262 #endif | 1275 #endif |
1263 | 1276 |
1264 cfun->last_verified = flags & TODO_verify_all; | 1277 cfun->last_verified = flags & TODO_verify_all; |
1351 dump_file_name = get_dump_file_name (pass->static_pass_number); | 1364 dump_file_name = get_dump_file_name (pass->static_pass_number); |
1352 dump_file = dump_begin (pass->static_pass_number, &dump_flags); | 1365 dump_file = dump_begin (pass->static_pass_number, &dump_flags); |
1353 if (dump_file && current_function_decl) | 1366 if (dump_file && current_function_decl) |
1354 { | 1367 { |
1355 const char *dname, *aname; | 1368 const char *dname, *aname; |
1369 struct cgraph_node *node = cgraph_node (current_function_decl); | |
1356 dname = lang_hooks.decl_printable_name (current_function_decl, 2); | 1370 dname = lang_hooks.decl_printable_name (current_function_decl, 2); |
1357 aname = (IDENTIFIER_POINTER | 1371 aname = (IDENTIFIER_POINTER |
1358 (DECL_ASSEMBLER_NAME (current_function_decl))); | 1372 (DECL_ASSEMBLER_NAME (current_function_decl))); |
1359 fprintf (dump_file, "\n;; Function %s (%s)%s\n\n", dname, aname, | 1373 fprintf (dump_file, "\n;; Function %s (%s)%s\n\n", dname, aname, |
1360 cfun->function_frequency == FUNCTION_FREQUENCY_HOT | 1374 node->frequency == NODE_FREQUENCY_HOT |
1361 ? " (hot)" | 1375 ? " (hot)" |
1362 : cfun->function_frequency == FUNCTION_FREQUENCY_UNLIKELY_EXECUTED | 1376 : node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED |
1363 ? " (unlikely executed)" | 1377 ? " (unlikely executed)" |
1378 : node->frequency == NODE_FREQUENCY_EXECUTED_ONCE | |
1379 ? " (executed once)" | |
1364 : ""); | 1380 : ""); |
1365 } | 1381 } |
1366 return initializing_dump; | 1382 return initializing_dump; |
1367 } | 1383 } |
1368 else | 1384 else |
1477 /* For the current function, execute all ipa transforms. */ | 1493 /* For the current function, execute all ipa transforms. */ |
1478 | 1494 |
1479 void | 1495 void |
1480 execute_all_ipa_transforms (void) | 1496 execute_all_ipa_transforms (void) |
1481 { | 1497 { |
1498 enum cgraph_state old_state = cgraph_state; | |
1482 struct cgraph_node *node; | 1499 struct cgraph_node *node; |
1483 if (!cfun) | 1500 if (!cfun) |
1484 return; | 1501 return; |
1485 node = cgraph_node (current_function_decl); | 1502 node = cgraph_node (current_function_decl); |
1503 | |
1504 /* Statement verification skip verification of nothorw when | |
1505 state is IPA_SSA because we do not modify function bodies | |
1506 after setting the flag on function. Instead we leave it | |
1507 to fixup_cfg to do such a transformation. We need to temporarily | |
1508 change the cgraph state so statement verifier before | |
1509 transform do not fire. */ | |
1510 cgraph_state = CGRAPH_STATE_IPA_SSA; | |
1511 | |
1486 if (node->ipa_transforms_to_apply) | 1512 if (node->ipa_transforms_to_apply) |
1487 { | 1513 { |
1488 unsigned int i; | 1514 unsigned int i; |
1489 | 1515 |
1490 for (i = 0; i < VEC_length (ipa_opt_pass, node->ipa_transforms_to_apply); | 1516 for (i = 0; i < VEC_length (ipa_opt_pass, node->ipa_transforms_to_apply); |
1494 node->ipa_transforms_to_apply, | 1520 node->ipa_transforms_to_apply, |
1495 i)); | 1521 i)); |
1496 VEC_free (ipa_opt_pass, heap, node->ipa_transforms_to_apply); | 1522 VEC_free (ipa_opt_pass, heap, node->ipa_transforms_to_apply); |
1497 node->ipa_transforms_to_apply = NULL; | 1523 node->ipa_transforms_to_apply = NULL; |
1498 } | 1524 } |
1525 cgraph_state = old_state; | |
1499 } | 1526 } |
1500 | 1527 |
1501 /* Execute PASS. */ | 1528 /* Execute PASS. */ |
1502 | 1529 |
1503 bool | 1530 bool |
1624 are local passes. If SET is not NULL, write out summaries of only | 1651 are local passes. If SET is not NULL, write out summaries of only |
1625 those node in SET. */ | 1652 those node in SET. */ |
1626 | 1653 |
1627 static void | 1654 static void |
1628 ipa_write_summaries_2 (struct opt_pass *pass, cgraph_node_set set, | 1655 ipa_write_summaries_2 (struct opt_pass *pass, cgraph_node_set set, |
1656 varpool_node_set vset, | |
1629 struct lto_out_decl_state *state) | 1657 struct lto_out_decl_state *state) |
1630 { | 1658 { |
1631 while (pass) | 1659 while (pass) |
1632 { | 1660 { |
1633 struct ipa_opt_pass_d *ipa_pass = (struct ipa_opt_pass_d *)pass; | 1661 struct ipa_opt_pass_d *ipa_pass = (struct ipa_opt_pass_d *)pass; |
1640 { | 1668 { |
1641 /* If a timevar is present, start it. */ | 1669 /* If a timevar is present, start it. */ |
1642 if (pass->tv_id) | 1670 if (pass->tv_id) |
1643 timevar_push (pass->tv_id); | 1671 timevar_push (pass->tv_id); |
1644 | 1672 |
1645 ipa_pass->write_summary (set); | 1673 ipa_pass->write_summary (set,vset); |
1646 | 1674 |
1647 /* If a timevar is present, start it. */ | 1675 /* If a timevar is present, start it. */ |
1648 if (pass->tv_id) | 1676 if (pass->tv_id) |
1649 timevar_pop (pass->tv_id); | 1677 timevar_pop (pass->tv_id); |
1650 } | 1678 } |
1651 | 1679 |
1652 if (pass->sub && pass->sub->type != GIMPLE_PASS) | 1680 if (pass->sub && pass->sub->type != GIMPLE_PASS) |
1653 ipa_write_summaries_2 (pass->sub, set, state); | 1681 ipa_write_summaries_2 (pass->sub, set, vset, state); |
1654 | 1682 |
1655 pass = pass->next; | 1683 pass = pass->next; |
1656 } | 1684 } |
1657 } | 1685 } |
1658 | 1686 |
1659 /* Helper function of ipa_write_summaries. Creates and destroys the | 1687 /* Helper function of ipa_write_summaries. Creates and destroys the |
1660 decl state and calls ipa_write_summaries_2 for all passes that have | 1688 decl state and calls ipa_write_summaries_2 for all passes that have |
1661 summaries. SET is the set of nodes to be written. */ | 1689 summaries. SET is the set of nodes to be written. */ |
1662 | 1690 |
1663 static void | 1691 static void |
1664 ipa_write_summaries_1 (cgraph_node_set set) | 1692 ipa_write_summaries_1 (cgraph_node_set set, varpool_node_set vset) |
1665 { | 1693 { |
1666 struct lto_out_decl_state *state = lto_new_out_decl_state (); | 1694 struct lto_out_decl_state *state = lto_new_out_decl_state (); |
1695 compute_ltrans_boundary (state, set, vset); | |
1696 | |
1667 lto_push_out_decl_state (state); | 1697 lto_push_out_decl_state (state); |
1668 | 1698 |
1669 if (!flag_wpa) | 1699 gcc_assert (!flag_wpa); |
1670 ipa_write_summaries_2 (all_regular_ipa_passes, set, state); | 1700 ipa_write_summaries_2 (all_regular_ipa_passes, set, vset, state); |
1671 ipa_write_summaries_2 (all_lto_gen_passes, set, state); | 1701 ipa_write_summaries_2 (all_lto_gen_passes, set, vset, state); |
1672 | 1702 |
1673 gcc_assert (lto_get_out_decl_state () == state); | 1703 gcc_assert (lto_get_out_decl_state () == state); |
1674 lto_pop_out_decl_state (); | 1704 lto_pop_out_decl_state (); |
1675 lto_delete_out_decl_state (state); | 1705 lto_delete_out_decl_state (state); |
1676 } | 1706 } |
1679 | 1709 |
1680 void | 1710 void |
1681 ipa_write_summaries (void) | 1711 ipa_write_summaries (void) |
1682 { | 1712 { |
1683 cgraph_node_set set; | 1713 cgraph_node_set set; |
1714 varpool_node_set vset; | |
1684 struct cgraph_node **order; | 1715 struct cgraph_node **order; |
1716 struct varpool_node *vnode; | |
1685 int i, order_pos; | 1717 int i, order_pos; |
1686 | 1718 |
1687 if (!flag_generate_lto || errorcount || sorrycount) | 1719 if (!flag_generate_lto || errorcount || sorrycount) |
1688 return; | 1720 return; |
1689 | 1721 |
1690 lto_new_extern_inline_states (); | |
1691 set = cgraph_node_set_new (); | 1722 set = cgraph_node_set_new (); |
1692 | 1723 |
1693 /* Create the callgraph set in the same order used in | 1724 /* Create the callgraph set in the same order used in |
1694 cgraph_expand_all_functions. This mostly facilitates debugging, | 1725 cgraph_expand_all_functions. This mostly facilitates debugging, |
1695 since it causes the gimple file to be processed in the same order | 1726 since it causes the gimple file to be processed in the same order |
1712 | 1743 |
1713 push_cfun (DECL_STRUCT_FUNCTION (node->decl)); | 1744 push_cfun (DECL_STRUCT_FUNCTION (node->decl)); |
1714 renumber_gimple_stmt_uids (); | 1745 renumber_gimple_stmt_uids (); |
1715 pop_cfun (); | 1746 pop_cfun (); |
1716 } | 1747 } |
1717 cgraph_node_set_add (set, node); | 1748 if (node->analyzed) |
1718 } | 1749 cgraph_node_set_add (set, node); |
1719 | 1750 } |
1720 ipa_write_summaries_1 (set); | 1751 vset = varpool_node_set_new (); |
1721 lto_delete_extern_inline_states (); | 1752 |
1753 for (vnode = varpool_nodes; vnode; vnode = vnode->next) | |
1754 if (vnode->needed && !vnode->alias) | |
1755 varpool_node_set_add (vset, vnode); | |
1756 | |
1757 ipa_write_summaries_1 (set, vset); | |
1722 | 1758 |
1723 free (order); | 1759 free (order); |
1724 ggc_free (set); | 1760 ggc_free (set); |
1725 } | 1761 ggc_free (vset); |
1726 | 1762 } |
1727 | 1763 |
1728 /* Write all the summaries for the cgraph nodes in SET. If SET is | 1764 /* Same as execute_pass_list but assume that subpasses of IPA passes |
1765 are local passes. If SET is not NULL, write out optimization summaries of | |
1766 only those node in SET. */ | |
1767 | |
1768 static void | |
1769 ipa_write_optimization_summaries_1 (struct opt_pass *pass, cgraph_node_set set, | |
1770 varpool_node_set vset, | |
1771 struct lto_out_decl_state *state) | |
1772 { | |
1773 while (pass) | |
1774 { | |
1775 struct ipa_opt_pass_d *ipa_pass = (struct ipa_opt_pass_d *)pass; | |
1776 gcc_assert (!current_function_decl); | |
1777 gcc_assert (!cfun); | |
1778 gcc_assert (pass->type == SIMPLE_IPA_PASS || pass->type == IPA_PASS); | |
1779 if (pass->type == IPA_PASS | |
1780 && ipa_pass->write_optimization_summary | |
1781 && (!pass->gate || pass->gate ())) | |
1782 { | |
1783 /* If a timevar is present, start it. */ | |
1784 if (pass->tv_id) | |
1785 timevar_push (pass->tv_id); | |
1786 | |
1787 ipa_pass->write_optimization_summary (set, vset); | |
1788 | |
1789 /* If a timevar is present, start it. */ | |
1790 if (pass->tv_id) | |
1791 timevar_pop (pass->tv_id); | |
1792 } | |
1793 | |
1794 if (pass->sub && pass->sub->type != GIMPLE_PASS) | |
1795 ipa_write_optimization_summaries_1 (pass->sub, set, vset, state); | |
1796 | |
1797 pass = pass->next; | |
1798 } | |
1799 } | |
1800 | |
1801 /* Write all the optimization summaries for the cgraph nodes in SET. If SET is | |
1729 NULL, write out all summaries of all nodes. */ | 1802 NULL, write out all summaries of all nodes. */ |
1730 | 1803 |
1731 void | 1804 void |
1732 ipa_write_summaries_of_cgraph_node_set (cgraph_node_set set) | 1805 ipa_write_optimization_summaries (cgraph_node_set set, varpool_node_set vset) |
1733 { | 1806 { |
1734 if (flag_generate_lto && !(errorcount || sorrycount)) | 1807 struct lto_out_decl_state *state = lto_new_out_decl_state (); |
1735 ipa_write_summaries_1 (set); | 1808 compute_ltrans_boundary (state, set, vset); |
1809 | |
1810 lto_push_out_decl_state (state); | |
1811 | |
1812 gcc_assert (flag_wpa); | |
1813 ipa_write_optimization_summaries_1 (all_regular_ipa_passes, set, vset, state); | |
1814 ipa_write_optimization_summaries_1 (all_lto_gen_passes, set, vset, state); | |
1815 | |
1816 gcc_assert (lto_get_out_decl_state () == state); | |
1817 lto_pop_out_decl_state (); | |
1818 lto_delete_out_decl_state (state); | |
1736 } | 1819 } |
1737 | 1820 |
1738 /* Same as execute_pass_list but assume that subpasses of IPA passes | 1821 /* Same as execute_pass_list but assume that subpasses of IPA passes |
1739 are local passes. */ | 1822 are local passes. */ |
1740 | 1823 |
1775 /* Read all the summaries for all_regular_ipa_passes and all_lto_gen_passes. */ | 1858 /* Read all the summaries for all_regular_ipa_passes and all_lto_gen_passes. */ |
1776 | 1859 |
1777 void | 1860 void |
1778 ipa_read_summaries (void) | 1861 ipa_read_summaries (void) |
1779 { | 1862 { |
1780 if (!flag_ltrans) | 1863 ipa_read_summaries_1 (all_regular_ipa_passes); |
1781 ipa_read_summaries_1 (all_regular_ipa_passes); | |
1782 ipa_read_summaries_1 (all_lto_gen_passes); | 1864 ipa_read_summaries_1 (all_lto_gen_passes); |
1865 } | |
1866 | |
1867 /* Same as execute_pass_list but assume that subpasses of IPA passes | |
1868 are local passes. */ | |
1869 | |
1870 static void | |
1871 ipa_read_optimization_summaries_1 (struct opt_pass *pass) | |
1872 { | |
1873 while (pass) | |
1874 { | |
1875 struct ipa_opt_pass_d *ipa_pass = (struct ipa_opt_pass_d *) pass; | |
1876 | |
1877 gcc_assert (!current_function_decl); | |
1878 gcc_assert (!cfun); | |
1879 gcc_assert (pass->type == SIMPLE_IPA_PASS || pass->type == IPA_PASS); | |
1880 | |
1881 if (pass->gate == NULL || pass->gate ()) | |
1882 { | |
1883 if (pass->type == IPA_PASS && ipa_pass->read_optimization_summary) | |
1884 { | |
1885 /* If a timevar is present, start it. */ | |
1886 if (pass->tv_id) | |
1887 timevar_push (pass->tv_id); | |
1888 | |
1889 ipa_pass->read_optimization_summary (); | |
1890 | |
1891 /* Stop timevar. */ | |
1892 if (pass->tv_id) | |
1893 timevar_pop (pass->tv_id); | |
1894 } | |
1895 | |
1896 if (pass->sub && pass->sub->type != GIMPLE_PASS) | |
1897 ipa_read_optimization_summaries_1 (pass->sub); | |
1898 } | |
1899 pass = pass->next; | |
1900 } | |
1901 } | |
1902 | |
1903 /* Read all the summaries for all_regular_ipa_passes and all_lto_gen_passes. */ | |
1904 | |
1905 void | |
1906 ipa_read_optimization_summaries (void) | |
1907 { | |
1908 ipa_read_optimization_summaries_1 (all_regular_ipa_passes); | |
1909 ipa_read_optimization_summaries_1 (all_lto_gen_passes); | |
1783 } | 1910 } |
1784 | 1911 |
1785 /* Same as execute_pass_list but assume that subpasses of IPA passes | 1912 /* Same as execute_pass_list but assume that subpasses of IPA passes |
1786 are local passes. */ | 1913 are local passes. */ |
1787 void | 1914 void |
1881 fprintf (dump, "PROP_no_crit_edges\n"); | 2008 fprintf (dump, "PROP_no_crit_edges\n"); |
1882 if (props & PROP_rtl) | 2009 if (props & PROP_rtl) |
1883 fprintf (dump, "PROP_rtl\n"); | 2010 fprintf (dump, "PROP_rtl\n"); |
1884 if (props & PROP_gimple_lomp) | 2011 if (props & PROP_gimple_lomp) |
1885 fprintf (dump, "PROP_gimple_lomp\n"); | 2012 fprintf (dump, "PROP_gimple_lomp\n"); |
2013 if (props & PROP_gimple_lcx) | |
2014 fprintf (dump, "PROP_gimple_lcx\n"); | |
1886 } | 2015 } |
1887 | 2016 |
1888 void | 2017 void |
1889 debug_properties (unsigned int props) | 2018 debug_properties (unsigned int props) |
1890 { | 2019 { |