00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "config.h"
00031 #undef FLOAT
00032 #undef FFS
00033 #include "system.h"
00034 #include "coretypes.h"
00035 #include "tm.h"
00036 #include <signal.h>
00037
00038 #ifdef HAVE_SYS_RESOURCE_H
00039 # include <sys/resource.h>
00040 #endif
00041
00042 #ifdef HAVE_SYS_TIMES_H
00043 # include <sys/times.h>
00044 #endif
00045
00046 #include "line-map.h"
00047 #include "input.h"
00048 #include "tree.h"
00049 #include "rtl.h"
00050 #include "tm_p.h"
00051 #include "flags.h"
00052 #include "insn-attr.h"
00053 #include "insn-config.h"
00054 #include "insn-flags.h"
00055 #include "hard-reg-set.h"
00056 #include "recog.h"
00057 #include "output.h"
00058 #include "except.h"
00059 #include "function.h"
00060 #include "toplev.h"
00061 #include "expr.h"
00062 #include "basic-block.h"
00063 #include "intl.h"
00064 #include "ggc.h"
00065 #include "graph.h"
00066 #include "regs.h"
00067 #include "timevar.h"
00068 #include "diagnostic.h"
00069 #include "params.h"
00070 #include "reload.h"
00071 #include "dwarf2asm.h"
00072 #include "integrate.h"
00073 #include "real.h"
00074 #include "debug.h"
00075 #include "target.h"
00076 #include "langhooks.h"
00077 #include "cfglayout.h"
00078 #include "cfgloop.h"
00079 #include "hosthooks.h"
00080 #include "cgraph.h"
00081 #include "opts.h"
00082 #include "coverage.h"
00083 #include "value-prof.h"
00084 #include "tree-inline.h"
00085 #include "tree-flow.h"
00086 #include "tree-pass.h"
00087 #include "tree-dump.h"
00088
00089 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
00090 #include "dwarf2out.h"
00091 #endif
00092
00093 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
00094 #include "dbxout.h"
00095 #endif
00096
00097 #ifdef SDB_DEBUGGING_INFO
00098 #include "sdbout.h"
00099 #endif
00100
00101 #ifdef XCOFF_DEBUGGING_INFO
00102 #include "xcoffout.h"
00103
00104 #endif
00105
00106 #ifdef KEY
00107 extern void gspin_gxx_emits_decl (tree);
00108 #endif
00109
00110
00111 int dump_flags;
00112 bool in_gimple_form;
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 void
00128 rest_of_decl_compilation (tree decl,
00129 int top_level,
00130 int at_end)
00131 {
00132
00133
00134 {
00135 tree alias;
00136 alias = lookup_attribute ("alias", DECL_ATTRIBUTES (decl));
00137 if (alias)
00138 {
00139 alias = TREE_VALUE (TREE_VALUE (alias));
00140 alias = get_identifier (TREE_STRING_POINTER (alias));
00141 assemble_alias (decl, alias);
00142 #ifdef KEY
00143
00144
00145
00146
00147 if (flag_spin_file)
00148 gspin_gxx_emits_decl(decl);
00149 #endif
00150 }
00151 }
00152
00153
00154
00155 if (DECL_ASSEMBLER_NAME_SET_P (decl) && DECL_REGISTER (decl))
00156 make_decl_rtl (decl);
00157
00158
00159
00160 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
00161 || TREE_CODE (decl) == FUNCTION_DECL)
00162 {
00163 timevar_push (TV_VARCONST);
00164
00165
00166
00167
00168
00169
00170
00171 if ((at_end
00172 || !DECL_DEFER_OUTPUT (decl)
00173 || DECL_INITIAL (decl))
00174 && !DECL_EXTERNAL (decl))
00175 {
00176 if (TREE_CODE (decl) != FUNCTION_DECL)
00177 cgraph_varpool_finalize_decl (decl);
00178 else
00179 assemble_variable (decl, top_level, at_end, 0);
00180 }
00181
00182 #ifdef ASM_FINISH_DECLARE_OBJECT
00183 if (decl == last_assemble_variable_decl)
00184 {
00185 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
00186 top_level, at_end);
00187 }
00188 #endif
00189
00190 timevar_pop (TV_VARCONST);
00191 }
00192 else if (TREE_CODE (decl) == TYPE_DECL
00193
00194
00195 && !(sorrycount || errorcount))
00196 {
00197 timevar_push (TV_SYMOUT);
00198 debug_hooks->type_decl (decl, !top_level);
00199 timevar_pop (TV_SYMOUT);
00200 }
00201
00202
00203 if (TREE_CODE (decl) == VAR_DECL && !DECL_EXTERNAL (decl))
00204 cgraph_varpool_node (decl);
00205 }
00206
00207
00208
00209 void
00210 rest_of_type_compilation (tree type, int toplev)
00211 {
00212
00213
00214 if (errorcount != 0 || sorrycount != 0)
00215 return;
00216
00217 timevar_push (TV_SYMOUT);
00218 debug_hooks->type_decl (TYPE_STUB_DECL (type), !toplev);
00219 timevar_pop (TV_SYMOUT);
00220 }
00221
00222
00223
00224 void
00225 finish_optimization_passes (void)
00226 {
00227 enum tree_dump_index i;
00228 struct dump_file_info *dfi;
00229 char *name;
00230
00231 timevar_push (TV_DUMP);
00232 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
00233 {
00234 dump_file = dump_begin (pass_profile.static_pass_number, NULL);
00235 end_branch_prob ();
00236 if (dump_file)
00237 dump_end (pass_profile.static_pass_number, dump_file);
00238 }
00239
00240 if (optimize > 0)
00241 {
00242 dump_file = dump_begin (pass_combine.static_pass_number, NULL);
00243 if (dump_file)
00244 {
00245 dump_combine_total_stats (dump_file);
00246 dump_end (pass_combine.static_pass_number, dump_file);
00247 }
00248 }
00249
00250
00251 if (graph_dump_format != no_graph)
00252 for (i = TDI_end; (dfi = get_dump_file_info (i)) != NULL; ++i)
00253 if (dump_initialized_p (i)
00254 && (dfi->flags & TDF_GRAPH) != 0
00255 && (name = get_dump_file_name (i)) != NULL)
00256 {
00257 finish_graph_dump_file (name);
00258 free (name);
00259 }
00260
00261 timevar_pop (TV_DUMP);
00262 }
00263
00264 static bool
00265 gate_rest_of_compilation (void)
00266 {
00267 #ifdef KEY
00268 if (flag_spin_file)
00269 gspin_gxx_emits_decl(current_function_decl);
00270 #endif
00271
00272
00273 return !(rtl_dump_and_exit || flag_syntax_only || errorcount || sorrycount);
00274 }
00275
00276 struct tree_opt_pass pass_rest_of_compilation =
00277 {
00278 NULL,
00279 gate_rest_of_compilation,
00280 NULL,
00281 NULL,
00282 NULL,
00283 0,
00284 TV_REST_OF_COMPILATION,
00285 PROP_rtl,
00286 0,
00287 0,
00288 0,
00289 TODO_ggc_collect,
00290 0
00291 };
00292
00293 static bool
00294 gate_postreload (void)
00295 {
00296 return reload_completed;
00297 }
00298
00299 struct tree_opt_pass pass_postreload =
00300 {
00301 NULL,
00302 gate_postreload,
00303 NULL,
00304 NULL,
00305 NULL,
00306 0,
00307 0,
00308 PROP_rtl,
00309 0,
00310 0,
00311 0,
00312 TODO_ggc_collect,
00313 0
00314 };
00315
00316
00317
00318
00319 struct tree_opt_pass *all_passes, *all_ipa_passes, *all_lowering_passes;
00320
00321
00322
00323
00324
00325 static void
00326 register_one_dump_file (struct tree_opt_pass *pass, bool ipa, int properties)
00327 {
00328 char *dot_name, *flag_name, *glob_name;
00329 const char *prefix;
00330 char num[10];
00331 int flags;
00332
00333
00334 num[0] = '\0';
00335 if (pass->static_pass_number != -1)
00336 sprintf (num, "%d", ((int) pass->static_pass_number < 0
00337 ? 1 : pass->static_pass_number));
00338
00339 dot_name = concat (".", pass->name, num, NULL);
00340 if (ipa)
00341 prefix = "ipa-", flags = TDF_IPA;
00342 else if (properties & PROP_trees)
00343 prefix = "tree-", flags = TDF_TREE;
00344 else
00345 prefix = "rtl-", flags = TDF_RTL;
00346
00347 flag_name = concat (prefix, pass->name, num, NULL);
00348 glob_name = concat (prefix, pass->name, NULL);
00349 pass->static_pass_number = dump_register (dot_name, flag_name, glob_name,
00350 flags, pass->letter);
00351 }
00352
00353
00354
00355 static int
00356 register_dump_files_1 (struct tree_opt_pass *pass, bool ipa, int properties)
00357 {
00358 do
00359 {
00360 int new_properties = (properties | pass->properties_provided)
00361 & ~pass->properties_destroyed;
00362
00363 if (pass->name)
00364 register_one_dump_file (pass, ipa, new_properties);
00365
00366 if (pass->sub)
00367 new_properties = register_dump_files_1 (pass->sub, false,
00368 new_properties);
00369
00370
00371
00372 if (pass->gate)
00373 properties &= new_properties;
00374 else
00375 properties = new_properties;
00376
00377 pass = pass->next;
00378 }
00379 while (pass);
00380
00381 return properties;
00382 }
00383
00384
00385
00386
00387
00388
00389 static void
00390 register_dump_files (struct tree_opt_pass *pass, bool ipa, int properties)
00391 {
00392 pass->properties_required |= properties;
00393 pass->todo_flags_start |= TODO_set_props;
00394 register_dump_files_1 (pass, ipa, properties);
00395 }
00396
00397
00398
00399
00400 static struct tree_opt_pass **
00401 next_pass_1 (struct tree_opt_pass **list, struct tree_opt_pass *pass)
00402 {
00403
00404
00405 if (pass->static_pass_number)
00406 {
00407 struct tree_opt_pass *new;
00408
00409 new = xmalloc (sizeof (*new));
00410 memcpy (new, pass, sizeof (*new));
00411
00412
00413
00414
00415
00416 if (pass->name)
00417 {
00418 pass->static_pass_number -= 1;
00419 new->static_pass_number = -pass->static_pass_number;
00420 }
00421
00422 *list = new;
00423 }
00424 else
00425 {
00426 pass->static_pass_number = -1;
00427 *list = pass;
00428 }
00429
00430 return &(*list)->next;
00431
00432 }
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454 void
00455 init_optimization_passes (void)
00456 {
00457 struct tree_opt_pass **p;
00458
00459 #define NEXT_PASS(PASS) (p = next_pass_1 (p, &PASS))
00460
00461 p = &all_ipa_passes;
00462 NEXT_PASS (pass_early_ipa_inline);
00463 NEXT_PASS (pass_early_local_passes);
00464 NEXT_PASS (pass_ipa_cp);
00465 NEXT_PASS (pass_ipa_inline);
00466 NEXT_PASS (pass_ipa_reference);
00467 NEXT_PASS (pass_ipa_pure_const);
00468 NEXT_PASS (pass_ipa_type_escape);
00469 NEXT_PASS (pass_ipa_pta);
00470 *p = NULL;
00471
00472
00473
00474 p = &all_lowering_passes;
00475 NEXT_PASS (pass_remove_useless_stmts);
00476 NEXT_PASS (pass_mudflap_1);
00477 NEXT_PASS (pass_lower_omp);
00478 NEXT_PASS (pass_lower_cf);
00479 NEXT_PASS (pass_lower_eh);
00480 NEXT_PASS (pass_build_cfg);
00481 NEXT_PASS (pass_lower_complex_O0);
00482 NEXT_PASS (pass_lower_vector);
00483 NEXT_PASS (pass_warn_function_return);
00484 NEXT_PASS (pass_early_tree_profile);
00485 *p = NULL;
00486
00487 p = &pass_early_local_passes.sub;
00488 NEXT_PASS (pass_tree_profile);
00489 NEXT_PASS (pass_cleanup_cfg);
00490 NEXT_PASS (pass_rebuild_cgraph_edges);
00491 *p = NULL;
00492
00493 p = &all_passes;
00494 NEXT_PASS (pass_fixup_cfg);
00495 NEXT_PASS (pass_init_datastructures);
00496 NEXT_PASS (pass_expand_omp);
00497 NEXT_PASS (pass_all_optimizations);
00498 NEXT_PASS (pass_warn_function_noreturn);
00499 NEXT_PASS (pass_mudflap_2);
00500 NEXT_PASS (pass_free_datastructures);
00501 NEXT_PASS (pass_free_cfg_annotations);
00502 NEXT_PASS (pass_expand);
00503 NEXT_PASS (pass_rest_of_compilation);
00504 NEXT_PASS (pass_clean_state);
00505 *p = NULL;
00506
00507 p = &pass_all_optimizations.sub;
00508 NEXT_PASS (pass_referenced_vars);
00509 NEXT_PASS (pass_reset_cc_flags);
00510 NEXT_PASS (pass_create_structure_vars);
00511 NEXT_PASS (pass_build_ssa);
00512 NEXT_PASS (pass_may_alias);
00513 NEXT_PASS (pass_return_slot);
00514 NEXT_PASS (pass_rename_ssa_copies);
00515 NEXT_PASS (pass_early_warn_uninitialized);
00516
00517
00518 NEXT_PASS (pass_ccp);
00519 NEXT_PASS (pass_fre);
00520 NEXT_PASS (pass_dce);
00521 NEXT_PASS (pass_forwprop);
00522 NEXT_PASS (pass_copy_prop);
00523 NEXT_PASS (pass_merge_phi);
00524 NEXT_PASS (pass_vrp);
00525 NEXT_PASS (pass_dce);
00526 NEXT_PASS (pass_dominator);
00527
00528
00529
00530
00531
00532
00533 NEXT_PASS (pass_phi_only_cprop);
00534
00535 NEXT_PASS (pass_phiopt);
00536 NEXT_PASS (pass_may_alias);
00537 NEXT_PASS (pass_tail_recursion);
00538 NEXT_PASS (pass_profile);
00539 NEXT_PASS (pass_ch);
00540 NEXT_PASS (pass_stdarg);
00541 NEXT_PASS (pass_lower_complex);
00542 NEXT_PASS (pass_sra);
00543
00544
00545
00546 NEXT_PASS (pass_may_alias);
00547 NEXT_PASS (pass_rename_ssa_copies);
00548 NEXT_PASS (pass_dominator);
00549
00550
00551
00552
00553
00554
00555 NEXT_PASS (pass_phi_only_cprop);
00556
00557 NEXT_PASS (pass_reassoc);
00558 NEXT_PASS (pass_dce);
00559 NEXT_PASS (pass_dse);
00560 NEXT_PASS (pass_may_alias);
00561 NEXT_PASS (pass_forwprop);
00562 NEXT_PASS (pass_phiopt);
00563 NEXT_PASS (pass_object_sizes);
00564 NEXT_PASS (pass_store_ccp);
00565 NEXT_PASS (pass_store_copy_prop);
00566 NEXT_PASS (pass_fold_builtins);
00567
00568
00569
00570 NEXT_PASS (pass_may_alias);
00571 NEXT_PASS (pass_split_crit_edges);
00572 NEXT_PASS (pass_pre);
00573 NEXT_PASS (pass_may_alias);
00574 NEXT_PASS (pass_sink_code);
00575 NEXT_PASS (pass_tree_loop);
00576 NEXT_PASS (pass_cse_reciprocals);
00577 NEXT_PASS (pass_reassoc);
00578 NEXT_PASS (pass_vrp);
00579 NEXT_PASS (pass_dominator);
00580
00581
00582
00583
00584
00585
00586 NEXT_PASS (pass_phi_only_cprop);
00587
00588 NEXT_PASS (pass_cd_dce);
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599 NEXT_PASS (pass_late_warn_uninitialized);
00600 NEXT_PASS (pass_dse);
00601 NEXT_PASS (pass_forwprop);
00602 NEXT_PASS (pass_phiopt);
00603 NEXT_PASS (pass_tail_calls);
00604 NEXT_PASS (pass_rename_ssa_copies);
00605 NEXT_PASS (pass_uncprop);
00606 NEXT_PASS (pass_del_ssa);
00607 NEXT_PASS (pass_nrv);
00608 NEXT_PASS (pass_mark_used_blocks);
00609 NEXT_PASS (pass_cleanup_cfg_post_optimizing);
00610 *p = NULL;
00611
00612 p = &pass_tree_loop.sub;
00613 NEXT_PASS (pass_tree_loop_init);
00614 NEXT_PASS (pass_copy_prop);
00615 NEXT_PASS (pass_lim);
00616 NEXT_PASS (pass_tree_unswitch);
00617 NEXT_PASS (pass_scev_cprop);
00618 NEXT_PASS (pass_empty_loop);
00619 NEXT_PASS (pass_record_bounds);
00620 NEXT_PASS (pass_linear_transform);
00621 NEXT_PASS (pass_iv_canon);
00622 NEXT_PASS (pass_if_conversion);
00623 NEXT_PASS (pass_vectorize);
00624
00625
00626
00627 NEXT_PASS (pass_complete_unroll);
00628 NEXT_PASS (pass_loop_prefetch);
00629 NEXT_PASS (pass_iv_optimize);
00630 NEXT_PASS (pass_tree_loop_done);
00631 *p = NULL;
00632
00633 p = &pass_vectorize.sub;
00634 NEXT_PASS (pass_lower_vector_ssa);
00635 NEXT_PASS (pass_dce_loop);
00636 *p = NULL;
00637
00638 p = &pass_loop2.sub;
00639 NEXT_PASS (pass_rtl_loop_init);
00640 NEXT_PASS (pass_rtl_move_loop_invariants);
00641 NEXT_PASS (pass_rtl_unswitch);
00642 NEXT_PASS (pass_rtl_unroll_and_peel_loops);
00643 NEXT_PASS (pass_rtl_doloop);
00644 NEXT_PASS (pass_rtl_loop_done);
00645 *p = NULL;
00646
00647 p = &pass_rest_of_compilation.sub;
00648 NEXT_PASS (pass_init_function);
00649 NEXT_PASS (pass_jump);
00650 NEXT_PASS (pass_insn_locators_initialize);
00651 NEXT_PASS (pass_rtl_eh);
00652 NEXT_PASS (pass_initial_value_sets);
00653 NEXT_PASS (pass_unshare_all_rtl);
00654 NEXT_PASS (pass_instantiate_virtual_regs);
00655 NEXT_PASS (pass_jump2);
00656 NEXT_PASS (pass_cse);
00657 NEXT_PASS (pass_gcse);
00658 NEXT_PASS (pass_jump_bypass);
00659 NEXT_PASS (pass_rtl_ifcvt);
00660 NEXT_PASS (pass_tracer);
00661
00662
00663
00664 NEXT_PASS (pass_loop2);
00665 NEXT_PASS (pass_web);
00666 NEXT_PASS (pass_cse2);
00667 NEXT_PASS (pass_life);
00668 NEXT_PASS (pass_combine);
00669 NEXT_PASS (pass_if_after_combine);
00670 NEXT_PASS (pass_partition_blocks);
00671 NEXT_PASS (pass_regmove);
00672 NEXT_PASS (pass_split_all_insns);
00673 NEXT_PASS (pass_mode_switching);
00674 NEXT_PASS (pass_see);
00675 NEXT_PASS (pass_recompute_reg_usage);
00676 NEXT_PASS (pass_sms);
00677 NEXT_PASS (pass_sched);
00678 NEXT_PASS (pass_local_alloc);
00679 NEXT_PASS (pass_global_alloc);
00680 NEXT_PASS (pass_postreload);
00681 *p = NULL;
00682
00683 p = &pass_postreload.sub;
00684 NEXT_PASS (pass_postreload_cse);
00685 NEXT_PASS (pass_gcse2);
00686 NEXT_PASS (pass_flow2);
00687 NEXT_PASS (pass_rtl_seqabstr);
00688 NEXT_PASS (pass_stack_adjustments);
00689 NEXT_PASS (pass_peephole2);
00690 NEXT_PASS (pass_if_after_reload);
00691 NEXT_PASS (pass_regrename);
00692 NEXT_PASS (pass_reorder_blocks);
00693 NEXT_PASS (pass_branch_target_load_optimize);
00694 NEXT_PASS (pass_leaf_regs);
00695 NEXT_PASS (pass_sched2);
00696 NEXT_PASS (pass_split_before_regstack);
00697 NEXT_PASS (pass_stack_regs);
00698 NEXT_PASS (pass_compute_alignments);
00699 NEXT_PASS (pass_duplicate_computed_gotos);
00700 NEXT_PASS (pass_variable_tracking);
00701 NEXT_PASS (pass_free_cfg);
00702 NEXT_PASS (pass_machine_reorg);
00703 NEXT_PASS (pass_purge_lineno_notes);
00704 NEXT_PASS (pass_cleanup_barriers);
00705 NEXT_PASS (pass_delay_slots);
00706 NEXT_PASS (pass_split_for_shorten_branches);
00707 NEXT_PASS (pass_convert_to_eh_region_ranges);
00708 NEXT_PASS (pass_shorten_branches);
00709 NEXT_PASS (pass_set_nothrow_function_flags);
00710 NEXT_PASS (pass_final);
00711 *p = NULL;
00712
00713 #undef NEXT_PASS
00714
00715
00716 register_dump_files (all_ipa_passes, true,
00717 PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh
00718 | PROP_cfg);
00719 register_dump_files (all_lowering_passes, false, PROP_gimple_any);
00720 register_dump_files (all_passes, false,
00721 PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh
00722 | PROP_cfg);
00723 }
00724
00725 static unsigned int last_verified;
00726 static unsigned int curr_properties;
00727
00728 static void
00729 execute_todo (unsigned int flags)
00730 {
00731 #if defined ENABLE_CHECKING
00732 if (need_ssa_update_p ())
00733 gcc_assert (flags & TODO_update_ssa_any);
00734 #endif
00735
00736 if (curr_properties & PROP_ssa)
00737 flags |= TODO_verify_ssa;
00738 flags &= ~last_verified;
00739 if (!flags)
00740 return;
00741
00742
00743 if (flags & TODO_update_smt_usage)
00744 recalculate_used_alone ();
00745
00746
00747 if (flags & TODO_cleanup_cfg)
00748 {
00749
00750 updating_used_alone = true;
00751
00752 if (current_loops)
00753 cleanup_tree_cfg_loop ();
00754 else
00755 cleanup_tree_cfg ();
00756
00757
00758 recalculate_used_alone ();
00759
00760
00761
00762
00763
00764
00765
00766 if (!(flags & TODO_update_ssa_any) && need_ssa_update_p ())
00767 flags |= TODO_update_ssa;
00768 }
00769
00770 if (flags & TODO_update_ssa_any)
00771 {
00772 unsigned update_flags = flags & TODO_update_ssa_any;
00773 update_ssa (update_flags);
00774 last_verified &= ~TODO_verify_ssa;
00775 }
00776
00777 if (flags & TODO_remove_unused_locals)
00778 remove_unused_locals ();
00779
00780 if ((flags & TODO_dump_func)
00781 && dump_file && current_function_decl)
00782 {
00783 if (curr_properties & PROP_trees)
00784 dump_function_to_file (current_function_decl,
00785 dump_file, dump_flags);
00786 else
00787 {
00788 if (dump_flags & TDF_SLIM)
00789 print_rtl_slim_with_bb (dump_file, get_insns (), dump_flags);
00790 else if ((curr_properties & PROP_cfg) && (dump_flags & TDF_BLOCKS))
00791 print_rtl_with_bb (dump_file, get_insns ());
00792 else
00793 print_rtl (dump_file, get_insns ());
00794
00795 if (curr_properties & PROP_cfg
00796 && graph_dump_format != no_graph
00797 && (dump_flags & TDF_GRAPH))
00798 print_rtl_graph_with_bb (dump_file_name, get_insns ());
00799 }
00800
00801
00802
00803 fflush (dump_file);
00804 }
00805 if ((flags & TODO_dump_cgraph)
00806 && dump_file && !current_function_decl)
00807 {
00808 dump_cgraph (dump_file);
00809
00810
00811 fflush (dump_file);
00812 }
00813
00814 if (flags & TODO_ggc_collect)
00815 {
00816 ggc_collect ();
00817 }
00818
00819 #if defined ENABLE_CHECKING
00820 if (flags & TODO_verify_ssa)
00821 verify_ssa (true);
00822 if (flags & TODO_verify_flow)
00823 verify_flow_info ();
00824 if (flags & TODO_verify_stmts)
00825 verify_stmts ();
00826 if (flags & TODO_verify_loops)
00827 verify_loop_closed_ssa ();
00828 #endif
00829
00830 last_verified = flags & TODO_verify_all;
00831 }
00832
00833
00834
00835
00836 static void
00837 verify_interpass_invariants (void)
00838 {
00839 #ifdef ENABLE_CHECKING
00840 gcc_assert (!fold_deferring_overflow_warnings_p ());
00841 #endif
00842 }
00843
00844 static bool
00845 execute_one_pass (struct tree_opt_pass *pass)
00846 {
00847 bool initializing_dump;
00848 unsigned int todo_after = 0;
00849
00850
00851 if (pass->gate && !pass->gate ())
00852 return false;
00853
00854 if (pass->todo_flags_start & TODO_set_props)
00855 curr_properties = pass->properties_required;
00856
00857
00858
00859 in_gimple_form = (curr_properties & PROP_trees) != 0;
00860
00861
00862 execute_todo (pass->todo_flags_start);
00863
00864 gcc_assert ((curr_properties & pass->properties_required)
00865 == pass->properties_required);
00866
00867 if (pass->properties_destroyed & PROP_smt_usage)
00868 updating_used_alone = true;
00869
00870
00871 if (pass->static_pass_number != -1)
00872 {
00873 initializing_dump = !dump_initialized_p (pass->static_pass_number);
00874 dump_file_name = get_dump_file_name (pass->static_pass_number);
00875 dump_file = dump_begin (pass->static_pass_number, &dump_flags);
00876 if (dump_file && current_function_decl)
00877 {
00878 const char *dname, *aname;
00879 dname = lang_hooks.decl_printable_name (current_function_decl, 2);
00880 aname = (IDENTIFIER_POINTER
00881 (DECL_ASSEMBLER_NAME (current_function_decl)));
00882 fprintf (dump_file, "\n;; Function %s (%s)%s\n\n", dname, aname,
00883 cfun->function_frequency == FUNCTION_FREQUENCY_HOT
00884 ? " (hot)"
00885 : cfun->function_frequency == FUNCTION_FREQUENCY_UNLIKELY_EXECUTED
00886 ? " (unlikely executed)"
00887 : "");
00888 }
00889 }
00890 else
00891 initializing_dump = false;
00892
00893
00894 if (pass->tv_id)
00895 timevar_push (pass->tv_id);
00896
00897
00898 if (pass->execute)
00899 {
00900 todo_after = pass->execute ();
00901 last_verified = 0;
00902 }
00903
00904
00905 if (pass->tv_id)
00906 timevar_pop (pass->tv_id);
00907
00908 curr_properties = (curr_properties | pass->properties_provided)
00909 & ~pass->properties_destroyed;
00910
00911 if (initializing_dump
00912 && dump_file
00913 && graph_dump_format != no_graph
00914 && (curr_properties & (PROP_cfg | PROP_rtl)) == (PROP_cfg | PROP_rtl))
00915 {
00916 get_dump_file_info (pass->static_pass_number)->flags |= TDF_GRAPH;
00917 dump_flags |= TDF_GRAPH;
00918 clean_graph_dump_file (dump_file_name);
00919 }
00920
00921
00922 execute_todo (todo_after | pass->todo_flags_finish);
00923 verify_interpass_invariants ();
00924
00925
00926 if (dump_file_name)
00927 {
00928 free ((char *) dump_file_name);
00929 dump_file_name = NULL;
00930 }
00931 if (dump_file)
00932 {
00933 dump_end (pass->static_pass_number, dump_file);
00934 dump_file = NULL;
00935 }
00936
00937 if (pass->properties_destroyed & PROP_smt_usage)
00938 updating_used_alone = false;
00939
00940
00941 in_gimple_form = false;
00942
00943 return true;
00944 }
00945
00946 void
00947 execute_pass_list (struct tree_opt_pass *pass)
00948 {
00949 do
00950 {
00951 if (execute_one_pass (pass) && pass->sub)
00952 execute_pass_list (pass->sub);
00953 pass = pass->next;
00954 }
00955 while (pass);
00956 }
00957
00958
00959
00960 void
00961 execute_ipa_pass_list (struct tree_opt_pass *pass)
00962 {
00963 do
00964 {
00965 if (execute_one_pass (pass) && pass->sub)
00966 {
00967 struct cgraph_node *node;
00968 for (node = cgraph_nodes; node; node = node->next)
00969 if (node->analyzed)
00970 {
00971 push_cfun (DECL_STRUCT_FUNCTION (node->decl));
00972 current_function_decl = node->decl;
00973 execute_pass_list (pass->sub);
00974 free_dominance_info (CDI_DOMINATORS);
00975 free_dominance_info (CDI_POST_DOMINATORS);
00976 current_function_decl = NULL;
00977 pop_cfun ();
00978 ggc_collect ();
00979 }
00980 }
00981 pass = pass->next;
00982 }
00983 while (pass);
00984 }