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
00031 #include "config.h"
00032 #undef FLOAT
00033 #undef FFS
00034 #include "system.h"
00035 #include "coretypes.h"
00036 #include "tm.h"
00037 #include <signal.h>
00038
00039 #ifdef HAVE_SYS_RESOURCE_H
00040 # include <sys/resource.h>
00041 #endif
00042
00043 #ifdef HAVE_SYS_TIMES_H
00044 # include <sys/times.h>
00045 #endif
00046
00047 #include "line-map.h"
00048 #include "input.h"
00049 #include "tree.h"
00050 #include "rtl.h"
00051 #include "tm_p.h"
00052 #include "flags.h"
00053 #include "insn-attr.h"
00054 #include "insn-config.h"
00055 #include "insn-flags.h"
00056 #include "hard-reg-set.h"
00057 #include "recog.h"
00058 #include "output.h"
00059 #include "except.h"
00060 #include "function.h"
00061 #include "toplev.h"
00062 #include "expr.h"
00063 #include "basic-block.h"
00064 #include "intl.h"
00065 #include "ggc.h"
00066 #include "graph.h"
00067 #include "regs.h"
00068 #include "timevar.h"
00069 #include "diagnostic.h"
00070 #include "params.h"
00071 #include "reload.h"
00072 #include "dwarf2asm.h"
00073 #include "integrate.h"
00074 #include "real.h"
00075 #include "debug.h"
00076 #include "target.h"
00077 #include "langhooks.h"
00078 #include "cfglayout.h"
00079 #include "cfgloop.h"
00080 #include "hosthooks.h"
00081 #include "cgraph.h"
00082 #include "opts.h"
00083 #include "coverage.h"
00084 #include "value-prof.h"
00085 #include "alloc-pool.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 #ifndef HAVE_conditional_execution
00107 #define HAVE_conditional_execution 0
00108 #endif
00109
00110
00111 #ifndef DUMPFILE_FORMAT
00112 #define DUMPFILE_FORMAT ".%02d."
00113 #endif
00114
00115 #ifdef KEY
00116 extern void gspin_gxx_emits_decl (tree);
00117 #endif
00118
00119 static int initializing_dump = 0;
00120
00121
00122
00123 static int
00124 open_dump_file (enum tree_dump_index index, tree decl)
00125 {
00126 if (! dump_enabled_p (index))
00127 return 0;
00128
00129 timevar_push (TV_DUMP);
00130
00131 if (dump_file != NULL || dump_file_name != NULL)
00132 abort ();
00133
00134 dump_file_name = get_dump_file_name (index);
00135 initializing_dump = !dump_initialized_p (index);
00136 dump_file = dump_begin (index, NULL);
00137
00138 if (dump_file == NULL)
00139 fatal_error ("can't open %s: %m", dump_file_name);
00140
00141 if (decl)
00142 fprintf (dump_file, "\n;; Function %s%s\n\n",
00143 lang_hooks.decl_printable_name (decl, 2),
00144 cfun->function_frequency == FUNCTION_FREQUENCY_HOT
00145 ? " (hot)"
00146 : cfun->function_frequency == FUNCTION_FREQUENCY_UNLIKELY_EXECUTED
00147 ? " (unlikely executed)"
00148 : "");
00149
00150 timevar_pop (TV_DUMP);
00151 return 1;
00152 }
00153
00154
00155
00156 static void
00157 close_dump_file (enum tree_dump_index index,
00158 void (*func) (FILE *, rtx),
00159 rtx insns)
00160 {
00161 if (! dump_file)
00162 return;
00163
00164 timevar_push (TV_DUMP);
00165 if (insns
00166 && graph_dump_format != no_graph)
00167 {
00168
00169 if (initializing_dump)
00170 {
00171 clean_graph_dump_file (dump_file_name);
00172 get_dump_file_info (index)->flags |= TDF_GRAPH;
00173 }
00174
00175 print_rtl_graph_with_bb (dump_file_name, insns);
00176 }
00177
00178 if (func && insns)
00179 func (dump_file, insns);
00180
00181 dump_end (index, dump_file);
00182 free ((char *) dump_file_name);
00183
00184 dump_file = NULL;
00185 dump_file_name = NULL;
00186 timevar_pop (TV_DUMP);
00187 }
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201 void
00202 rest_of_decl_compilation (tree decl,
00203 int top_level,
00204 int at_end)
00205 {
00206
00207
00208 {
00209 tree alias;
00210 alias = lookup_attribute ("alias", DECL_ATTRIBUTES (decl));
00211 if (alias)
00212 {
00213 alias = TREE_VALUE (TREE_VALUE (alias));
00214 alias = get_identifier (TREE_STRING_POINTER (alias));
00215 assemble_alias (decl, alias);
00216 #ifdef KEY
00217
00218
00219
00220
00221 if (flag_spin_file)
00222 gspin_gxx_emits_decl(decl);
00223 #endif
00224 }
00225 }
00226
00227
00228
00229 if (DECL_REGISTER (decl) && DECL_ASSEMBLER_NAME_SET_P (decl))
00230 make_decl_rtl (decl);
00231
00232
00233
00234 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
00235 || TREE_CODE (decl) == FUNCTION_DECL)
00236 {
00237 timevar_push (TV_VARCONST);
00238
00239
00240
00241
00242
00243
00244
00245 if ((at_end
00246 || !DECL_DEFER_OUTPUT (decl)
00247 || (flag_unit_at_a_time && DECL_INITIAL (decl)))
00248 && !DECL_EXTERNAL (decl))
00249 {
00250 if (flag_unit_at_a_time && !cgraph_global_info_ready
00251 && TREE_CODE (decl) != FUNCTION_DECL && top_level)
00252 cgraph_varpool_finalize_decl (decl);
00253 else
00254 assemble_variable (decl, top_level, at_end, 0);
00255 }
00256
00257 #ifdef ASM_FINISH_DECLARE_OBJECT
00258 if (decl == last_assemble_variable_decl)
00259 {
00260 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
00261 top_level, at_end);
00262 }
00263 #endif
00264
00265 timevar_pop (TV_VARCONST);
00266 }
00267 else if (TREE_CODE (decl) == TYPE_DECL
00268
00269
00270 && !(sorrycount || errorcount))
00271 {
00272 timevar_push (TV_SYMOUT);
00273 debug_hooks->type_decl (decl, !top_level);
00274 timevar_pop (TV_SYMOUT);
00275 }
00276
00277
00278 if (TREE_CODE (decl) == VAR_DECL && !DECL_EXTERNAL (decl))
00279 cgraph_varpool_node (decl);
00280 }
00281
00282
00283
00284 void
00285 rest_of_type_compilation (tree type, int toplev)
00286 {
00287
00288
00289 if (errorcount != 0 || sorrycount != 0)
00290 return;
00291
00292 timevar_push (TV_SYMOUT);
00293 debug_hooks->type_decl (TYPE_STUB_DECL (type), !toplev);
00294 timevar_pop (TV_SYMOUT);
00295 }
00296
00297
00298 static void
00299 rest_of_handle_final (void)
00300 {
00301 timevar_push (TV_FINAL);
00302 {
00303 rtx x;
00304 const char *fnname;
00305
00306
00307
00308
00309 x = DECL_RTL (current_function_decl);
00310 if (!MEM_P (x))
00311 abort ();
00312 x = XEXP (x, 0);
00313 if (GET_CODE (x) != SYMBOL_REF)
00314 abort ();
00315 fnname = XSTR (x, 0);
00316
00317 assemble_start_function (current_function_decl, fnname);
00318 final_start_function (get_insns (), asm_out_file, optimize);
00319 final (get_insns (), asm_out_file, optimize, 0);
00320 final_end_function ();
00321
00322 #ifdef TARGET_UNWIND_INFO
00323
00324
00325 output_function_exception_table ();
00326 #endif
00327
00328 assemble_end_function (current_function_decl, fnname);
00329
00330 #ifndef TARGET_UNWIND_INFO
00331
00332 output_function_exception_table ();
00333 #endif
00334
00335 user_defined_section_attribute = false;
00336
00337 if (! quiet_flag)
00338 fflush (asm_out_file);
00339
00340
00341 free_basic_block_vars ();
00342 }
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355 timevar_push (TV_SYMOUT);
00356 (*debug_hooks->function_decl) (current_function_decl);
00357 timevar_pop (TV_SYMOUT);
00358
00359 ggc_collect ();
00360 timevar_pop (TV_FINAL);
00361 }
00362
00363 #ifdef DELAY_SLOTS
00364
00365 static void
00366 rest_of_handle_delay_slots (void)
00367 {
00368 timevar_push (TV_DBR_SCHED);
00369 open_dump_file (DFI_dbr, current_function_decl);
00370
00371 dbr_schedule (get_insns (), dump_file);
00372
00373 close_dump_file (DFI_dbr, print_rtl, get_insns ());
00374
00375 ggc_collect ();
00376
00377 timevar_pop (TV_DBR_SCHED);
00378 }
00379 #endif
00380
00381 #ifdef STACK_REGS
00382
00383
00384 static void
00385 rest_of_handle_stack_regs (void)
00386 {
00387 #if defined (HAVE_ATTR_length)
00388
00389
00390
00391
00392 #ifdef INSN_SCHEDULING
00393 if (optimize && !flag_schedule_insns_after_reload)
00394 #else
00395 if (optimize)
00396 #endif
00397 {
00398 timevar_push (TV_SHORTEN_BRANCH);
00399 split_all_insns (1);
00400 timevar_pop (TV_SHORTEN_BRANCH);
00401 }
00402 #endif
00403
00404 timevar_push (TV_REG_STACK);
00405 open_dump_file (DFI_stack, current_function_decl);
00406
00407 if (reg_to_stack (dump_file) && optimize)
00408 {
00409 if (cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK
00410 | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0))
00411 && (flag_reorder_blocks || flag_reorder_blocks_and_partition))
00412 {
00413 reorder_basic_blocks (0);
00414 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK);
00415 }
00416 }
00417
00418 close_dump_file (DFI_stack, print_rtl_with_bb, get_insns ());
00419
00420 ggc_collect ();
00421 timevar_pop (TV_REG_STACK);
00422 }
00423 #endif
00424
00425
00426 static void
00427 rest_of_handle_variable_tracking (void)
00428 {
00429 timevar_push (TV_VAR_TRACKING);
00430 open_dump_file (DFI_vartrack, current_function_decl);
00431
00432 variable_tracking_main ();
00433
00434 close_dump_file (DFI_vartrack, print_rtl_with_bb, get_insns ());
00435 timevar_pop (TV_VAR_TRACKING);
00436 }
00437
00438
00439 static void
00440 rest_of_handle_machine_reorg (void)
00441 {
00442 timevar_push (TV_MACH_DEP);
00443 open_dump_file (DFI_mach, current_function_decl);
00444
00445 targetm.machine_dependent_reorg ();
00446
00447 close_dump_file (DFI_mach, print_rtl, get_insns ());
00448
00449 ggc_collect ();
00450 timevar_pop (TV_MACH_DEP);
00451 }
00452
00453
00454
00455
00456 static bool
00457 rest_of_handle_old_regalloc (void)
00458 {
00459 int failure;
00460 int rebuild_notes;
00461
00462 timevar_push (TV_LOCAL_ALLOC);
00463 open_dump_file (DFI_lreg, current_function_decl);
00464
00465
00466 allocate_reg_info (max_regno, FALSE, TRUE);
00467
00468
00469 VARRAY_GROW (reg_equiv_memory_loc_varray, max_regno);
00470 reg_equiv_memory_loc = &VARRAY_RTX (reg_equiv_memory_loc_varray, 0);
00471
00472 allocate_initial_values (reg_equiv_memory_loc);
00473
00474 regclass (get_insns (), max_reg_num (), dump_file);
00475 rebuild_notes = local_alloc ();
00476
00477 timevar_pop (TV_LOCAL_ALLOC);
00478
00479
00480
00481
00482 if (rebuild_notes)
00483 {
00484 timevar_push (TV_JUMP);
00485
00486 rebuild_jump_labels (get_insns ());
00487 purge_all_dead_edges (0);
00488 delete_unreachable_blocks ();
00489
00490 timevar_pop (TV_JUMP);
00491 }
00492
00493 if (dump_enabled_p (DFI_lreg))
00494 {
00495 timevar_push (TV_DUMP);
00496 dump_flow_info (dump_file);
00497 dump_local_alloc (dump_file);
00498 timevar_pop (TV_DUMP);
00499 }
00500
00501 close_dump_file (DFI_lreg, print_rtl_with_bb, get_insns ());
00502
00503 ggc_collect ();
00504
00505 timevar_push (TV_GLOBAL_ALLOC);
00506 open_dump_file (DFI_greg, current_function_decl);
00507
00508
00509
00510
00511 if (optimize)
00512 failure = global_alloc (dump_file);
00513 else
00514 {
00515 build_insn_chain (get_insns ());
00516 failure = reload (get_insns (), 0);
00517 }
00518
00519 if (dump_enabled_p (DFI_greg))
00520 {
00521 timevar_push (TV_DUMP);
00522 dump_global_regs (dump_file);
00523 timevar_pop (TV_DUMP);
00524
00525 close_dump_file (DFI_greg, print_rtl_with_bb, get_insns ());
00526 }
00527
00528 ggc_collect ();
00529
00530 timevar_pop (TV_GLOBAL_ALLOC);
00531
00532 return failure;
00533 }
00534
00535
00536 static void
00537 rest_of_handle_regrename (void)
00538 {
00539 timevar_push (TV_RENAME_REGISTERS);
00540 open_dump_file (DFI_rnreg, current_function_decl);
00541
00542 if (flag_rename_registers)
00543 regrename_optimize ();
00544 if (flag_cprop_registers)
00545 copyprop_hardreg_forward ();
00546
00547 close_dump_file (DFI_rnreg, print_rtl_with_bb, get_insns ());
00548 timevar_pop (TV_RENAME_REGISTERS);
00549 }
00550
00551
00552 static void
00553 rest_of_handle_reorder_blocks (void)
00554 {
00555 bool changed;
00556 unsigned int liveness_flags;
00557
00558 open_dump_file (DFI_bbro, current_function_decl);
00559
00560
00561
00562 liveness_flags = (!HAVE_conditional_execution ? CLEANUP_UPDATE_LIFE : 0);
00563 changed = cleanup_cfg (CLEANUP_EXPENSIVE | liveness_flags);
00564
00565 if (flag_sched2_use_traces && flag_schedule_insns_after_reload)
00566 tracer (liveness_flags);
00567 if (flag_reorder_blocks || flag_reorder_blocks_and_partition)
00568 reorder_basic_blocks (liveness_flags);
00569 if (flag_reorder_blocks || flag_reorder_blocks_and_partition
00570 || (flag_sched2_use_traces && flag_schedule_insns_after_reload))
00571 changed |= cleanup_cfg (CLEANUP_EXPENSIVE | liveness_flags);
00572
00573
00574
00575
00576 if (changed && HAVE_conditional_execution)
00577 update_life_info (NULL, UPDATE_LIFE_GLOBAL_RM_NOTES,
00578 PROP_DEATH_NOTES);
00579 close_dump_file (DFI_bbro, print_rtl_with_bb, get_insns ());
00580 }
00581
00582
00583 static void
00584 rest_of_handle_partition_blocks (void)
00585 {
00586 no_new_pseudos = 0;
00587 partition_hot_cold_basic_blocks ();
00588 allocate_reg_life_data ();
00589 update_life_info (NULL, UPDATE_LIFE_GLOBAL_RM_NOTES,
00590 PROP_LOG_LINKS | PROP_REG_INFO | PROP_DEATH_NOTES);
00591 no_new_pseudos = 1;
00592 }
00593
00594 #ifdef INSN_SCHEDULING
00595
00596
00597 static void
00598 rest_of_handle_sms (void)
00599 {
00600 sbitmap blocks;
00601
00602 timevar_push (TV_SMS);
00603 open_dump_file (DFI_sms, current_function_decl);
00604
00605
00606 no_new_pseudos = 0;
00607 sms_schedule (dump_file);
00608 close_dump_file (DFI_sms, print_rtl, get_insns ());
00609
00610
00611
00612 max_regno = max_reg_num ();
00613 allocate_reg_info (max_regno, FALSE, FALSE);
00614 blocks = sbitmap_alloc (last_basic_block);
00615 sbitmap_ones (blocks);
00616 update_life_info (blocks, UPDATE_LIFE_GLOBAL_RM_NOTES,
00617 (PROP_DEATH_NOTES
00618 | PROP_REG_INFO
00619 | PROP_KILL_DEAD_CODE
00620 | PROP_SCAN_DEAD_CODE));
00621
00622 no_new_pseudos = 1;
00623
00624 ggc_collect ();
00625 timevar_pop (TV_SMS);
00626 }
00627
00628
00629 static void
00630 rest_of_handle_sched (void)
00631 {
00632 timevar_push (TV_SCHED);
00633
00634
00635
00636 open_dump_file (DFI_sched, current_function_decl);
00637
00638
00639
00640
00641 schedule_insns (dump_file);
00642
00643 close_dump_file (DFI_sched, print_rtl_with_bb, get_insns ());
00644
00645 ggc_collect ();
00646 timevar_pop (TV_SCHED);
00647 }
00648
00649
00650 static void
00651 rest_of_handle_sched2 (void)
00652 {
00653 timevar_push (TV_SCHED2);
00654 open_dump_file (DFI_sched2, current_function_decl);
00655
00656
00657
00658
00659 split_all_insns (1);
00660
00661 if (flag_sched2_use_superblocks || flag_sched2_use_traces)
00662 {
00663 schedule_ebbs (dump_file);
00664
00665
00666 count_or_remove_death_notes (NULL, 1);
00667 cleanup_cfg (CLEANUP_EXPENSIVE);
00668 }
00669 else
00670 schedule_insns (dump_file);
00671
00672 close_dump_file (DFI_sched2, print_rtl_with_bb, get_insns ());
00673
00674 ggc_collect ();
00675
00676 timevar_pop (TV_SCHED2);
00677 }
00678 #endif
00679
00680 static void
00681 rest_of_handle_gcse2 (void)
00682 {
00683 timevar_push (TV_GCSE_AFTER_RELOAD);
00684 open_dump_file (DFI_gcse2, current_function_decl);
00685
00686 gcse_after_reload_main (get_insns ());
00687 rebuild_jump_labels (get_insns ());
00688 delete_trivially_dead_insns (get_insns (), max_reg_num ());
00689 close_dump_file (DFI_gcse2, print_rtl_with_bb, get_insns ());
00690
00691 ggc_collect ();
00692
00693 #ifdef ENABLE_CHECKING
00694 verify_flow_info ();
00695 #endif
00696
00697 timevar_pop (TV_GCSE_AFTER_RELOAD);
00698 }
00699
00700
00701
00702 static void
00703 rest_of_handle_regmove (void)
00704 {
00705 timevar_push (TV_REGMOVE);
00706 open_dump_file (DFI_regmove, current_function_decl);
00707
00708 regmove_optimize (get_insns (), max_reg_num (), dump_file);
00709
00710 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
00711 close_dump_file (DFI_regmove, print_rtl_with_bb, get_insns ());
00712
00713 ggc_collect ();
00714 timevar_pop (TV_REGMOVE);
00715 }
00716
00717
00718 static void
00719 rest_of_handle_tracer (void)
00720 {
00721 open_dump_file (DFI_tracer, current_function_decl);
00722 if (dump_file)
00723 dump_flow_info (dump_file);
00724 tracer (0);
00725 cleanup_cfg (CLEANUP_EXPENSIVE);
00726 reg_scan (get_insns (), max_reg_num ());
00727 close_dump_file (DFI_tracer, print_rtl_with_bb, get_insns ());
00728 }
00729
00730
00731 static void
00732 rest_of_handle_if_conversion (void)
00733 {
00734 timevar_push (TV_IFCVT);
00735 open_dump_file (DFI_ce1, current_function_decl);
00736
00737 if (flag_if_conversion)
00738 {
00739 if (dump_file)
00740 dump_flow_info (dump_file);
00741 cleanup_cfg (CLEANUP_EXPENSIVE);
00742 reg_scan (get_insns (), max_reg_num ());
00743 if_convert (0);
00744 }
00745
00746 timevar_push (TV_JUMP);
00747 cleanup_cfg (CLEANUP_EXPENSIVE);
00748 reg_scan (get_insns (), max_reg_num ());
00749 timevar_pop (TV_JUMP);
00750
00751 close_dump_file (DFI_ce1, print_rtl_with_bb, get_insns ());
00752 timevar_pop (TV_IFCVT);
00753 }
00754
00755
00756
00757 static void
00758 rest_of_handle_if_after_combine (void)
00759 {
00760 timevar_push (TV_IFCVT);
00761 open_dump_file (DFI_ce2, current_function_decl);
00762
00763 no_new_pseudos = 0;
00764 if_convert (1);
00765 no_new_pseudos = 1;
00766
00767 close_dump_file (DFI_ce2, print_rtl_with_bb, get_insns ());
00768 timevar_pop (TV_IFCVT);
00769 }
00770
00771 static void
00772 rest_of_handle_if_after_reload (void)
00773 {
00774 timevar_push (TV_IFCVT2);
00775 open_dump_file (DFI_ce3, current_function_decl);
00776
00777
00778
00779 cleanup_cfg (CLEANUP_EXPENSIVE
00780 | CLEANUP_UPDATE_LIFE
00781 | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0));
00782 if (flag_if_conversion2)
00783 if_convert (1);
00784 close_dump_file (DFI_ce3, print_rtl_with_bb, get_insns ());
00785 timevar_pop (TV_IFCVT2);
00786 }
00787
00788 static void
00789 rest_of_handle_web (void)
00790 {
00791 open_dump_file (DFI_web, current_function_decl);
00792 timevar_push (TV_WEB);
00793 web_main ();
00794 delete_trivially_dead_insns (get_insns (), max_reg_num ());
00795 cleanup_cfg (CLEANUP_EXPENSIVE);
00796
00797 timevar_pop (TV_WEB);
00798 close_dump_file (DFI_web, print_rtl_with_bb, get_insns ());
00799 reg_scan (get_insns (), max_reg_num ());
00800 }
00801
00802
00803 static void
00804 rest_of_handle_branch_prob (void)
00805 {
00806 struct loops loops;
00807
00808 timevar_push (TV_BRANCH_PROB);
00809 open_dump_file (DFI_bp, current_function_decl);
00810
00811 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
00812 branch_prob ();
00813
00814
00815
00816 flow_loops_find (&loops, LOOP_TREE);
00817
00818 if (dump_file)
00819 flow_loops_dump (&loops, dump_file, NULL, 0);
00820
00821
00822 if (flag_guess_branch_prob)
00823 estimate_probability (&loops);
00824
00825 flow_loops_free (&loops);
00826 free_dominance_info (CDI_DOMINATORS);
00827 close_dump_file (DFI_bp, print_rtl_with_bb, get_insns ());
00828 timevar_pop (TV_BRANCH_PROB);
00829 }
00830
00831
00832 static void
00833 rest_of_handle_value_profile_transformations (void)
00834 {
00835 open_dump_file (DFI_vpt, current_function_decl);
00836 timevar_push (TV_VPT);
00837
00838 if (value_profile_transformations ())
00839 cleanup_cfg (CLEANUP_EXPENSIVE);
00840
00841 timevar_pop (TV_VPT);
00842 close_dump_file (DFI_vpt, print_rtl_with_bb, get_insns ());
00843 }
00844
00845
00846
00847 static void
00848 rest_of_handle_cfg (void)
00849 {
00850 open_dump_file (DFI_cfg, current_function_decl);
00851 if (dump_file)
00852 dump_flow_info (dump_file);
00853 if (optimize)
00854 cleanup_cfg (CLEANUP_EXPENSIVE
00855 | (flag_thread_jumps ? CLEANUP_THREADING : 0));
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869 if (optimize
00870 && (!flag_tree_based_profiling
00871 || (!profile_arc_flag && !flag_branch_probabilities)))
00872 {
00873
00874
00875 reg_scan (get_insns (), max_reg_num ());
00876 mark_constant_function ();
00877 }
00878
00879 close_dump_file (DFI_cfg, print_rtl_with_bb, get_insns ());
00880 }
00881
00882
00883 static void
00884 rest_of_handle_jump_bypass (void)
00885 {
00886 timevar_push (TV_BYPASS);
00887 open_dump_file (DFI_bypass, current_function_decl);
00888
00889 cleanup_cfg (CLEANUP_EXPENSIVE);
00890 reg_scan (get_insns (), max_reg_num ());
00891
00892 if (bypass_jumps (dump_file))
00893 {
00894 rebuild_jump_labels (get_insns ());
00895 cleanup_cfg (CLEANUP_EXPENSIVE);
00896 delete_trivially_dead_insns (get_insns (), max_reg_num ());
00897 }
00898
00899 close_dump_file (DFI_bypass, print_rtl_with_bb, get_insns ());
00900 timevar_pop (TV_BYPASS);
00901
00902 ggc_collect ();
00903
00904 #ifdef ENABLE_CHECKING
00905 verify_flow_info ();
00906 #endif
00907 }
00908
00909
00910 static void
00911 rest_of_handle_combine (void)
00912 {
00913 int rebuild_jump_labels_after_combine = 0;
00914
00915 timevar_push (TV_COMBINE);
00916 open_dump_file (DFI_combine, current_function_decl);
00917
00918 rebuild_jump_labels_after_combine
00919 = combine_instructions (get_insns (), max_reg_num ());
00920
00921
00922
00923
00924 if (rebuild_jump_labels_after_combine)
00925 {
00926 timevar_push (TV_JUMP);
00927 rebuild_jump_labels (get_insns ());
00928 timevar_pop (TV_JUMP);
00929
00930 delete_dead_jumptables ();
00931 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
00932 }
00933
00934 close_dump_file (DFI_combine, print_rtl_with_bb, get_insns ());
00935 timevar_pop (TV_COMBINE);
00936
00937 ggc_collect ();
00938 }
00939
00940
00941 static void
00942 rest_of_handle_life (void)
00943 {
00944 open_dump_file (DFI_life, current_function_decl);
00945 regclass_init ();
00946
00947 #ifdef ENABLE_CHECKING
00948 verify_flow_info ();
00949 #endif
00950 life_analysis (dump_file, PROP_FINAL);
00951 if (optimize)
00952 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE | CLEANUP_LOG_LINKS
00953 | (flag_thread_jumps ? CLEANUP_THREADING : 0));
00954
00955 if (extra_warnings)
00956 {
00957 setjmp_vars_warning (DECL_INITIAL (current_function_decl));
00958 setjmp_args_warning ();
00959 }
00960
00961 if (optimize)
00962 {
00963 if (initialize_uninitialized_subregs ())
00964 {
00965
00966
00967 allocate_reg_life_data ();
00968 update_life_info (NULL, UPDATE_LIFE_GLOBAL_RM_NOTES,
00969 PROP_LOG_LINKS | PROP_REG_INFO | PROP_DEATH_NOTES);
00970 }
00971 }
00972
00973 no_new_pseudos = 1;
00974
00975 close_dump_file (DFI_life, print_rtl_with_bb, get_insns ());
00976
00977 ggc_collect ();
00978 }
00979
00980
00981
00982
00983 static void
00984 rest_of_handle_cse (void)
00985 {
00986 int tem;
00987
00988 open_dump_file (DFI_cse, current_function_decl);
00989 if (dump_file)
00990 dump_flow_info (dump_file);
00991 timevar_push (TV_CSE);
00992
00993 reg_scan (get_insns (), max_reg_num ());
00994
00995 tem = cse_main (get_insns (), max_reg_num (), dump_file);
00996 if (tem)
00997 rebuild_jump_labels (get_insns ());
00998 if (purge_all_dead_edges (0))
00999 delete_unreachable_blocks ();
01000
01001 delete_trivially_dead_insns (get_insns (), max_reg_num ());
01002
01003
01004
01005 cse_not_expected = !flag_rerun_cse_after_loop && !flag_gcse;
01006
01007 if (tem)
01008 delete_dead_jumptables ();
01009
01010 if (tem || optimize > 1)
01011 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
01012
01013 timevar_pop (TV_CSE);
01014 close_dump_file (DFI_cse, print_rtl_with_bb, get_insns ());
01015
01016 ggc_collect ();
01017 }
01018
01019
01020 static void
01021 rest_of_handle_cse2 (void)
01022 {
01023 int tem;
01024
01025 timevar_push (TV_CSE2);
01026 open_dump_file (DFI_cse2, current_function_decl);
01027 if (dump_file)
01028 dump_flow_info (dump_file);
01029
01030 tem = cse_main (get_insns (), max_reg_num (), dump_file);
01031
01032
01033
01034
01035
01036 cse_condition_code_reg ();
01037
01038 purge_all_dead_edges (0);
01039 delete_trivially_dead_insns (get_insns (), max_reg_num ());
01040
01041 if (tem)
01042 {
01043 timevar_push (TV_JUMP);
01044 rebuild_jump_labels (get_insns ());
01045 delete_dead_jumptables ();
01046 cleanup_cfg (CLEANUP_EXPENSIVE);
01047 timevar_pop (TV_JUMP);
01048 }
01049 reg_scan (get_insns (), max_reg_num ());
01050 close_dump_file (DFI_cse2, print_rtl_with_bb, get_insns ());
01051 timevar_pop (TV_CSE2);
01052
01053 ggc_collect ();
01054 }
01055
01056
01057 static void
01058 rest_of_handle_gcse (void)
01059 {
01060 int save_csb, save_cfj;
01061 int tem2 = 0, tem;
01062
01063 timevar_push (TV_GCSE);
01064 open_dump_file (DFI_gcse, current_function_decl);
01065
01066 tem = gcse_main (get_insns (), dump_file);
01067 rebuild_jump_labels (get_insns ());
01068 delete_trivially_dead_insns (get_insns (), max_reg_num ());
01069
01070 save_csb = flag_cse_skip_blocks;
01071 save_cfj = flag_cse_follow_jumps;
01072 flag_cse_skip_blocks = flag_cse_follow_jumps = 0;
01073
01074
01075
01076 if (flag_expensive_optimizations)
01077 {
01078 timevar_push (TV_CSE);
01079 reg_scan (get_insns (), max_reg_num ());
01080 tem2 = cse_main (get_insns (), max_reg_num (), dump_file);
01081 purge_all_dead_edges (0);
01082 delete_trivially_dead_insns (get_insns (), max_reg_num ());
01083 timevar_pop (TV_CSE);
01084 cse_not_expected = !flag_rerun_cse_after_loop;
01085 }
01086
01087
01088
01089 if (tem || tem2)
01090 {
01091 timevar_push (TV_JUMP);
01092 rebuild_jump_labels (get_insns ());
01093 delete_dead_jumptables ();
01094 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
01095 timevar_pop (TV_JUMP);
01096 }
01097
01098 close_dump_file (DFI_gcse, print_rtl_with_bb, get_insns ());
01099 timevar_pop (TV_GCSE);
01100
01101 ggc_collect ();
01102 flag_cse_skip_blocks = save_csb;
01103 flag_cse_follow_jumps = save_cfj;
01104 #ifdef ENABLE_CHECKING
01105 verify_flow_info ();
01106 #endif
01107 }
01108
01109
01110 static void
01111 rest_of_handle_loop_optimize (void)
01112 {
01113 int do_prefetch;
01114
01115 timevar_push (TV_LOOP);
01116 open_dump_file (DFI_loop, current_function_decl);
01117
01118
01119 free_bb_for_insn ();
01120 profile_status = PROFILE_ABSENT;
01121
01122 do_prefetch = flag_prefetch_loop_arrays ? LOOP_PREFETCH : 0;
01123
01124 if (flag_rerun_loop_opt)
01125 {
01126 cleanup_barriers ();
01127
01128
01129 loop_optimize (get_insns (), dump_file, 0);
01130
01131
01132
01133
01134
01135 delete_trivially_dead_insns (get_insns (), max_reg_num ());
01136
01137
01138
01139 reg_scan (get_insns (), max_reg_num ());
01140 }
01141 cleanup_barriers ();
01142 loop_optimize (get_insns (), dump_file, do_prefetch);
01143
01144
01145 delete_trivially_dead_insns (get_insns (), max_reg_num ());
01146 find_basic_blocks (get_insns ());
01147 close_dump_file (DFI_loop, print_rtl, get_insns ());
01148 timevar_pop (TV_LOOP);
01149
01150 ggc_collect ();
01151 }
01152
01153
01154
01155
01156 static void
01157 rest_of_handle_loop2 (void)
01158 {
01159 struct loops *loops;
01160 basic_block bb;
01161
01162 if (!flag_move_loop_invariants
01163 && !flag_unswitch_loops
01164 && !flag_peel_loops
01165 && !flag_unroll_loops
01166 && !flag_branch_on_count_reg)
01167 return;
01168
01169 timevar_push (TV_LOOP);
01170 open_dump_file (DFI_loop2, current_function_decl);
01171 if (dump_file)
01172 dump_flow_info (dump_file);
01173
01174
01175 cfg_layout_initialize (0);
01176
01177 loops = loop_optimizer_init (dump_file);
01178
01179 if (loops)
01180 {
01181
01182 if (flag_move_loop_invariants)
01183 move_loop_invariants (loops);
01184
01185 if (flag_unswitch_loops)
01186 unswitch_loops (loops);
01187
01188 if (flag_peel_loops || flag_unroll_loops)
01189 unroll_and_peel_loops (loops,
01190 (flag_peel_loops ? UAP_PEEL : 0) |
01191 (flag_unroll_loops ? UAP_UNROLL : 0) |
01192 (flag_unroll_all_loops ? UAP_UNROLL_ALL : 0));
01193
01194 #ifdef HAVE_doloop_end
01195 if (flag_branch_on_count_reg && HAVE_doloop_end)
01196 doloop_optimize_loops (loops);
01197 #endif
01198
01199 loop_optimizer_finalize (loops, dump_file);
01200 }
01201
01202 free_dominance_info (CDI_DOMINATORS);
01203
01204
01205 FOR_EACH_BB (bb)
01206 if (bb->next_bb != EXIT_BLOCK_PTR)
01207 bb->rbi->next = bb->next_bb;
01208 cfg_layout_finalize ();
01209
01210 cleanup_cfg (CLEANUP_EXPENSIVE);
01211 delete_trivially_dead_insns (get_insns (), max_reg_num ());
01212 reg_scan (get_insns (), max_reg_num ());
01213 if (dump_file)
01214 dump_flow_info (dump_file);
01215 close_dump_file (DFI_loop2, print_rtl_with_bb, get_insns ());
01216 timevar_pop (TV_LOOP);
01217 ggc_collect ();
01218 }
01219
01220 static void
01221 rest_of_handle_branch_target_load_optimize (void)
01222 {
01223 static int warned = 0;
01224
01225
01226
01227
01228 if (flag_branch_target_load_optimize
01229 && flag_branch_target_load_optimize2
01230 && !warned)
01231 {
01232 warning ("branch target register load optimization is not intended "
01233 "to be run twice");
01234
01235 warned = 1;
01236 }
01237
01238 open_dump_file (DFI_branch_target_load, current_function_decl);
01239 branch_target_load_optimize (epilogue_completed);
01240 close_dump_file (DFI_branch_target_load, print_rtl_with_bb, get_insns ());
01241 ggc_collect ();
01242 }
01243
01244 #ifdef OPTIMIZE_MODE_SWITCHING
01245 static void
01246 rest_of_handle_mode_switching (void)
01247 {
01248 timevar_push (TV_MODE_SWITCH);
01249
01250 no_new_pseudos = 0;
01251 optimize_mode_switching (NULL);
01252 no_new_pseudos = 1;
01253
01254 timevar_pop (TV_MODE_SWITCH);
01255 }
01256 #endif
01257
01258 static void
01259 rest_of_handle_jump (void)
01260 {
01261 ggc_collect ();
01262
01263 timevar_push (TV_JUMP);
01264 open_dump_file (DFI_sibling, current_function_decl);
01265
01266 delete_unreachable_blocks ();
01267 #ifdef ENABLE_CHECKING
01268 verify_flow_info ();
01269 #endif
01270
01271 if (cfun->tail_call_emit)
01272 fixup_tail_calls ();
01273
01274 close_dump_file (DFI_sibling, print_rtl, get_insns ());
01275 timevar_pop (TV_JUMP);
01276 }
01277
01278 static void
01279 rest_of_handle_eh (void)
01280 {
01281 insn_locators_initialize ();
01282
01283 if (doing_eh (0))
01284 {
01285 timevar_push (TV_JUMP);
01286 open_dump_file (DFI_eh, current_function_decl);
01287
01288 cleanup_cfg (CLEANUP_PRE_LOOP | CLEANUP_NO_INSN_DEL);
01289
01290 finish_eh_generation ();
01291
01292 cleanup_cfg (CLEANUP_PRE_LOOP | CLEANUP_NO_INSN_DEL);
01293
01294 close_dump_file (DFI_eh, print_rtl, get_insns ());
01295 timevar_pop (TV_JUMP);
01296 }
01297 }
01298
01299 static void
01300 rest_of_handle_stack_adjustments (void)
01301 {
01302 life_analysis (dump_file, PROP_POSTRELOAD);
01303 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE
01304 | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0));
01305
01306
01307
01308
01309
01310 #ifndef PUSH_ROUNDING
01311 if (!ACCUMULATE_OUTGOING_ARGS)
01312 #endif
01313 combine_stack_adjustments ();
01314 }
01315
01316 static void
01317 rest_of_handle_flow2 (void)
01318 {
01319 timevar_push (TV_FLOW2);
01320 open_dump_file (DFI_flow2, current_function_decl);
01321
01322
01323 #ifdef ENABLE_CHECKING
01324 verify_flow_info ();
01325 #endif
01326
01327
01328 #ifndef STACK_REGS
01329 if (optimize > 0)
01330 #endif
01331 split_all_insns (0);
01332
01333 if (flag_branch_target_load_optimize)
01334 {
01335 close_dump_file (DFI_flow2, print_rtl_with_bb, get_insns ());
01336 rest_of_handle_branch_target_load_optimize ();
01337 open_dump_file (DFI_flow2, current_function_decl);
01338 }
01339
01340 if (optimize)
01341 cleanup_cfg (CLEANUP_EXPENSIVE);
01342
01343
01344
01345
01346
01347 thread_prologue_and_epilogue_insns (get_insns ());
01348 epilogue_completed = 1;
01349
01350 if (optimize)
01351 rest_of_handle_stack_adjustments ();
01352
01353 flow2_completed = 1;
01354
01355 close_dump_file (DFI_flow2, print_rtl_with_bb, get_insns ());
01356 timevar_pop (TV_FLOW2);
01357
01358 ggc_collect ();
01359 }
01360
01361
01362 static void
01363 rest_of_handle_jump2 (void)
01364 {
01365 open_dump_file (DFI_jump, current_function_decl);
01366
01367
01368
01369
01370
01371 timevar_push (TV_JUMP);
01372
01373
01374 if (flag_guess_branch_prob)
01375 expected_value_to_br_prob ();
01376
01377 delete_trivially_dead_insns (get_insns (), max_reg_num ());
01378 reg_scan (get_insns (), max_reg_num ());
01379 if (dump_file)
01380 dump_flow_info (dump_file);
01381 cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0) | CLEANUP_PRE_LOOP
01382 | (flag_thread_jumps ? CLEANUP_THREADING : 0));
01383
01384 create_loop_notes ();
01385
01386 purge_line_number_notes (get_insns ());
01387
01388 if (optimize)
01389 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
01390
01391
01392
01393
01394
01395
01396 renumber_insns (dump_file);
01397
01398 close_dump_file (DFI_jump, print_rtl_with_bb, get_insns ());
01399 timevar_pop (TV_JUMP);
01400
01401 ggc_collect ();
01402 }
01403
01404 #ifdef HAVE_peephole2
01405 static void
01406 rest_of_handle_peephole2 (void)
01407 {
01408 timevar_push (TV_PEEPHOLE2);
01409 open_dump_file (DFI_peephole2, current_function_decl);
01410
01411 peephole2_optimize (dump_file);
01412
01413 close_dump_file (DFI_peephole2, print_rtl_with_bb, get_insns ());
01414 timevar_pop (TV_PEEPHOLE2);
01415 }
01416 #endif
01417
01418 static void
01419 rest_of_handle_postreload (void)
01420 {
01421 timevar_push (TV_RELOAD_CSE_REGS);
01422 open_dump_file (DFI_postreload, current_function_decl);
01423
01424
01425 reload_cse_regs (get_insns ());
01426
01427
01428 if (flag_non_call_exceptions)
01429 purge_all_dead_edges (0);
01430
01431 close_dump_file (DFI_postreload, print_rtl_with_bb, get_insns ());
01432 timevar_pop (TV_RELOAD_CSE_REGS);
01433 }
01434
01435 static void
01436 rest_of_handle_shorten_branches (void)
01437 {
01438
01439 timevar_push (TV_SHORTEN_BRANCH);
01440 shorten_branches (get_insns ());
01441 timevar_pop (TV_SHORTEN_BRANCH);
01442 }
01443
01444 static void
01445 rest_of_clean_state (void)
01446 {
01447 rtx insn, next;
01448 coverage_end_function ();
01449
01450
01451
01452
01453
01454 for (insn = get_insns (); insn; insn = next)
01455 {
01456 next = NEXT_INSN (insn);
01457 NEXT_INSN (insn) = NULL;
01458 PREV_INSN (insn) = NULL;
01459 }
01460
01461
01462
01463
01464 #ifdef SDB_DEBUGGING_INFO
01465 if (write_symbols == SDB_DEBUG)
01466 sdbout_types (NULL_TREE);
01467 #endif
01468
01469 reload_completed = 0;
01470 epilogue_completed = 0;
01471 flow2_completed = 0;
01472 no_new_pseudos = 0;
01473
01474 timevar_push (TV_FINAL);
01475
01476
01477
01478 init_insn_lengths ();
01479
01480
01481 init_temp_slots ();
01482
01483 free_basic_block_vars ();
01484 free_bb_for_insn ();
01485
01486 timevar_pop (TV_FINAL);
01487
01488 if (targetm.binds_local_p (current_function_decl))
01489 {
01490 int pref = cfun->preferred_stack_boundary;
01491 if (cfun->stack_alignment_needed > cfun->preferred_stack_boundary)
01492 pref = cfun->stack_alignment_needed;
01493 cgraph_rtl_info (current_function_decl)->preferred_incoming_stack_boundary
01494 = pref;
01495 }
01496
01497
01498
01499
01500
01501
01502
01503
01504
01505
01506 init_recog_no_volatile ();
01507
01508
01509 free_after_parsing (cfun);
01510 free_after_compilation (cfun);
01511 }
01512
01513
01514
01515
01516
01517
01518
01519
01520
01521
01522
01523 static void
01524 rest_of_compilation (void)
01525 {
01526 #ifdef KEY
01527 if (flag_spin_file)
01528 gspin_gxx_emits_decl(current_function_decl);
01529 #endif
01530
01531
01532
01533 {
01534 tree parent;
01535 for (parent = DECL_CONTEXT (current_function_decl);
01536 parent != NULL_TREE;
01537 parent = get_containing_scope (parent))
01538 if (TREE_CODE (parent) == FUNCTION_DECL)
01539 TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (parent)) = 1;
01540 }
01541
01542
01543
01544
01545 if (cgraph_function_possibly_inlined_p (current_function_decl))
01546 (*debug_hooks->outlining_inline_function) (current_function_decl);
01547
01548
01549
01550
01551 remove_unnecessary_notes ();
01552
01553
01554 init_function_for_compilation ();
01555
01556 TREE_ASM_WRITTEN (current_function_decl) = 1;
01557
01558
01559
01560 if (rtl_dump_and_exit || flag_syntax_only || errorcount || sorrycount)
01561 goto exit_rest_of_compilation;
01562
01563 rest_of_handle_jump ();
01564
01565 rest_of_handle_eh ();
01566
01567
01568
01569 emit_initial_value_sets ();
01570
01571 #ifdef FINALIZE_PIC
01572
01573
01574
01575
01576 if (flag_pic)
01577 FINALIZE_PIC;
01578 #endif
01579
01580
01581 unshare_all_rtl ();
01582
01583 #ifdef SETJMP_VIA_SAVE_AREA
01584
01585
01586
01587
01588 if (current_function_calls_alloca)
01589 optimize_save_area_alloca ();
01590 #endif
01591
01592
01593 instantiate_virtual_regs ();
01594
01595 rest_of_handle_jump2 ();
01596
01597 if (optimize > 0)
01598 rest_of_handle_cse ();
01599
01600 if (optimize > 0)
01601 {
01602 if (flag_gcse)
01603 rest_of_handle_gcse ();
01604
01605 if (flag_loop_optimize)
01606 rest_of_handle_loop_optimize ();
01607
01608 if (flag_gcse)
01609 rest_of_handle_jump_bypass ();
01610 }
01611
01612 timevar_push (TV_FLOW);
01613 rest_of_handle_cfg ();
01614
01615 if (!flag_tree_based_profiling
01616 && (optimize > 0 || profile_arc_flag
01617 || flag_test_coverage || flag_branch_probabilities))
01618 {
01619 rtl_register_profile_hooks ();
01620 rtl_register_value_prof_hooks ();
01621 rest_of_handle_branch_prob ();
01622
01623 if (flag_branch_probabilities
01624 && flag_profile_values
01625 && (flag_value_profile_transformations
01626 || flag_speculative_prefetching))
01627 rest_of_handle_value_profile_transformations ();
01628
01629
01630 if (flag_profile_values)
01631 count_or_remove_death_notes (NULL, 1);
01632 }
01633
01634 if (optimize > 0)
01635 rest_of_handle_if_conversion ();
01636
01637 if (optimize > 0 && flag_tracer)
01638 rest_of_handle_tracer ();
01639
01640 if (optimize > 0
01641 && flag_loop_optimize2)
01642 rest_of_handle_loop2 ();
01643
01644 if (optimize > 0 && flag_web)
01645 rest_of_handle_web ();
01646
01647 if (optimize > 0 && flag_rerun_cse_after_loop)
01648 rest_of_handle_cse2 ();
01649
01650 cse_not_expected = 1;
01651
01652 rest_of_handle_life ();
01653 timevar_pop (TV_FLOW);
01654
01655 if (optimize > 0)
01656 rest_of_handle_combine ();
01657
01658 if (optimize > 0 && flag_if_conversion)
01659 rest_of_handle_if_after_combine ();
01660
01661
01662
01663
01664
01665
01666 if (flag_reorder_blocks_and_partition
01667 && !DECL_ONE_ONLY (current_function_decl)
01668 && !user_defined_section_attribute)
01669 rest_of_handle_partition_blocks ();
01670
01671 if (optimize > 0 && flag_regmove)
01672 rest_of_handle_regmove ();
01673
01674
01675
01676 split_all_insns (1);
01677
01678 #ifdef OPTIMIZE_MODE_SWITCHING
01679 rest_of_handle_mode_switching ();
01680 #endif
01681
01682
01683
01684
01685 recompute_reg_usage ();
01686
01687 #ifdef INSN_SCHEDULING
01688 if (optimize > 0 && flag_modulo_sched)
01689 rest_of_handle_sms ();
01690
01691 if (flag_schedule_insns)
01692 rest_of_handle_sched ();
01693 #endif
01694
01695
01696
01697
01698 current_function_is_leaf = leaf_function_p ();
01699
01700 if (rest_of_handle_old_regalloc ())
01701 goto exit_rest_of_compilation;
01702
01703 if (optimize > 0)
01704 rest_of_handle_postreload ();
01705
01706 if (optimize > 0 && flag_gcse_after_reload)
01707 rest_of_handle_gcse2 ();
01708
01709 rest_of_handle_flow2 ();
01710
01711 #ifdef HAVE_peephole2
01712 if (optimize > 0 && flag_peephole2)
01713 rest_of_handle_peephole2 ();
01714 #endif
01715
01716 if (optimize > 0)
01717 rest_of_handle_if_after_reload ();
01718
01719 if (optimize > 0)
01720 {
01721 if (flag_rename_registers || flag_cprop_registers)
01722 rest_of_handle_regrename ();
01723
01724 rest_of_handle_reorder_blocks ();
01725 }
01726
01727 if (flag_branch_target_load_optimize2)
01728 rest_of_handle_branch_target_load_optimize ();
01729
01730 #ifdef LEAF_REGISTERS
01731 current_function_uses_only_leaf_regs
01732 = optimize > 0 && only_leaf_regs_used () && leaf_function_p ();
01733 #endif
01734
01735 #ifdef INSN_SCHEDULING
01736 if (optimize > 0 && flag_schedule_insns_after_reload)
01737 rest_of_handle_sched2 ();
01738 #endif
01739
01740 #ifdef STACK_REGS
01741 rest_of_handle_stack_regs ();
01742 #endif
01743
01744 compute_alignments ();
01745
01746
01747
01748 if (flag_expensive_optimizations && !optimize_size)
01749 duplicate_computed_gotos ();
01750
01751 if (flag_var_tracking)
01752 rest_of_handle_variable_tracking ();
01753
01754
01755 free_bb_for_insn ();
01756
01757 if (targetm.machine_dependent_reorg != 0)
01758 rest_of_handle_machine_reorg ();
01759
01760 purge_line_number_notes (get_insns ());
01761 cleanup_barriers ();
01762
01763 #ifdef DELAY_SLOTS
01764 if (flag_delayed_branch)
01765 rest_of_handle_delay_slots ();
01766 #endif
01767
01768 #if defined (HAVE_ATTR_length) && !defined (STACK_REGS)
01769 timevar_push (TV_SHORTEN_BRANCH);
01770 split_all_insns_noflow ();
01771 timevar_pop (TV_SHORTEN_BRANCH);
01772 #endif
01773
01774 convert_to_eh_region_ranges ();
01775
01776 rest_of_handle_shorten_branches ();
01777
01778 set_nothrow_function_flags ();
01779
01780 rest_of_handle_final ();
01781
01782 exit_rest_of_compilation:
01783
01784 rest_of_clean_state ();
01785 }
01786
01787 void
01788 finish_optimization_passes (void)
01789 {
01790 enum tree_dump_index i;
01791 struct dump_file_info *dfi;
01792 char *name;
01793
01794 timevar_push (TV_DUMP);
01795 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
01796 {
01797 open_dump_file (DFI_bp, NULL);
01798 end_branch_prob ();
01799 close_dump_file (DFI_bp, NULL, NULL_RTX);
01800 }
01801
01802 if (optimize > 0 && open_dump_file (DFI_combine, NULL))
01803 {
01804 dump_combine_total_stats (dump_file);
01805 close_dump_file (DFI_combine, NULL, NULL_RTX);
01806 }
01807
01808
01809 if (graph_dump_format != no_graph)
01810 for (i = DFI_MIN; (dfi = get_dump_file_info (i)) != NULL; ++i)
01811 if (dump_initialized_p (i)
01812 && (dfi->flags & TDF_GRAPH) != 0
01813 && (name = get_dump_file_name (i)) != NULL)
01814 {
01815 finish_graph_dump_file (name);
01816 free (name);
01817 }
01818
01819 timevar_pop (TV_DUMP);
01820 }
01821
01822 struct tree_opt_pass pass_rest_of_compilation =
01823 {
01824 NULL,
01825 NULL,
01826 rest_of_compilation,
01827 NULL,
01828 NULL,
01829 0,
01830 TV_REST_OF_COMPILATION,
01831 PROP_rtl,
01832 0,
01833 PROP_rtl,
01834 0,
01835 TODO_ggc_collect,
01836 0
01837 };
01838
01839