OSDN Git Service

108d18583adbdb4824e03f79ea65aca1e3c57d77
[pf3gnuchains/gcc-fork.git] / gcc / passes.c
1 /* Top level of GCC compilers (cc1, cc1plus, etc.)
2    Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3    1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
4
5 This file is part of GCC.
6
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
10 version.
11
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING.  If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA.  */
21
22 /* This is the top level of cc1/c++.
23    It parses command args, opens files, invokes the various passes
24    in the proper order, and counts the time used by each.
25    Error messages and low-level interface to malloc also handled here.  */
26
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"
31 #include "coretypes.h"
32 #include "tm.h"
33 #include <signal.h>
34
35 #ifdef HAVE_SYS_RESOURCE_H
36 # include <sys/resource.h>
37 #endif
38
39 #ifdef HAVE_SYS_TIMES_H
40 # include <sys/times.h>
41 #endif
42
43 #include "line-map.h"
44 #include "input.h"
45 #include "tree.h"
46 #include "rtl.h"
47 #include "tm_p.h"
48 #include "flags.h"
49 #include "insn-attr.h"
50 #include "insn-config.h"
51 #include "insn-flags.h"
52 #include "hard-reg-set.h"
53 #include "recog.h"
54 #include "output.h"
55 #include "except.h"
56 #include "function.h"
57 #include "toplev.h"
58 #include "expr.h"
59 #include "basic-block.h"
60 #include "intl.h"
61 #include "ggc.h"
62 #include "graph.h"
63 #include "loop.h"
64 #include "regs.h"
65 #include "timevar.h"
66 #include "diagnostic.h"
67 #include "params.h"
68 #include "reload.h"
69 #include "dwarf2asm.h"
70 #include "integrate.h"
71 #include "real.h"
72 #include "debug.h"
73 #include "target.h"
74 #include "langhooks.h"
75 #include "cfglayout.h"
76 #include "cfgloop.h"
77 #include "hosthooks.h"
78 #include "cgraph.h"
79 #include "opts.h"
80 #include "coverage.h"
81 #include "value-prof.h"
82 #include "alloc-pool.h"
83 #include "tree-pass.h"
84
85 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
86 #include "dwarf2out.h"
87 #endif
88
89 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
90 #include "dbxout.h"
91 #endif
92
93 #ifdef SDB_DEBUGGING_INFO
94 #include "sdbout.h"
95 #endif
96
97 #ifdef XCOFF_DEBUGGING_INFO
98 #include "xcoffout.h"           /* Needed for external data
99                                    declarations for e.g. AIX 4.x.  */
100 #endif
101
102 #ifndef HAVE_conditional_execution
103 #define HAVE_conditional_execution 0
104 #endif
105
106 /* Format to use to print dumpfile index value */
107 #ifndef DUMPFILE_FORMAT
108 #define DUMPFILE_FORMAT ".%02d."
109 #endif
110
111 /* Describes a dump file.  */
112
113 struct dump_file_info
114 {
115   /* The unique extension to apply, e.g. ".jump".  */
116   const char *const extension;
117
118   /* The -d<c> character that enables this dump file.  */
119   char const debug_switch;
120
121   /* True if there is a corresponding graph dump file.  */
122   char const graph_dump_p;
123
124   /* True if the user selected this dump.  */
125   char enabled;
126
127   /* True if the files have been initialized (ie truncated).  */
128   char initialized;
129 };
130
131 /* Enumerate the extant dump files.  */
132
133 enum dump_file_index
134 {
135   DFI_cgraph,
136   DFI_rtl,
137   DFI_sibling,
138   DFI_eh,
139   DFI_jump,
140   DFI_null,
141   DFI_cse,
142   DFI_gcse,
143   DFI_loop,
144   DFI_bypass,
145   DFI_cfg,
146   DFI_bp,
147   DFI_vpt,
148   DFI_ce1,
149   DFI_tracer,
150   DFI_loop2,
151   DFI_web,
152   DFI_cse2,
153   DFI_life,
154   DFI_combine,
155   DFI_ce2,
156   DFI_regmove,
157   DFI_sms,
158   DFI_sched,
159   DFI_lreg,
160   DFI_greg,
161   DFI_postreload,
162   DFI_gcse2,
163   DFI_flow2,
164   DFI_peephole2,
165   DFI_ce3,
166   DFI_rnreg,
167   DFI_bbro,
168   DFI_branch_target_load,
169   DFI_sched2,
170   DFI_stack,
171   DFI_vartrack,
172   DFI_mach,
173   DFI_dbr,
174   DFI_MAX
175 };
176
177 /* Describes all the dump files.  Should be kept in order of the
178    pass and in sync with dump_file_index above.
179
180    Remaining -d letters:
181
182         "   e            q         "
183         "    F     K   O Q     WXY "
184 */
185
186 static struct dump_file_info dump_file_tbl[DFI_MAX] =
187 {
188   { "cgraph",   'U', 0, 0, 0 },
189   { "rtl",      'r', 0, 0, 0 },
190   { "sibling",  'i', 0, 0, 0 },
191   { "eh",       'h', 0, 0, 0 },
192   { "jump",     'j', 0, 0, 0 },
193   { "null",     'u', 0, 0, 0 },
194   { "cse",      's', 0, 0, 0 },
195   { "gcse",     'G', 1, 0, 0 },
196   { "loop",     'L', 1, 0, 0 },
197   { "bypass",   'G', 1, 0, 0 }, /* Yes, duplicate enable switch.  */
198   { "cfg",      'f', 1, 0, 0 },
199   { "bp",       'b', 1, 0, 0 },
200   { "vpt",      'V', 1, 0, 0 },
201   { "ce1",      'C', 1, 0, 0 },
202   { "tracer",   'T', 1, 0, 0 },
203   { "loop2",    'L', 1, 0, 0 },
204   { "web",      'Z', 0, 0, 0 },
205   { "cse2",     't', 1, 0, 0 },
206   { "life",     'f', 1, 0, 0 }, /* Yes, duplicate enable switch.  */
207   { "combine",  'c', 1, 0, 0 },
208   { "ce2",      'C', 1, 0, 0 },
209   { "regmove",  'N', 1, 0, 0 },
210   { "sms",      'm', 0, 0, 0 },
211   { "sched",    'S', 1, 0, 0 },
212   { "lreg",     'l', 1, 0, 0 },
213   { "greg",     'g', 1, 0, 0 },
214   { "postreload", 'o', 1, 0, 0 },
215   { "gcse2",    'J', 0, 0, 0 },
216   { "flow2",    'w', 1, 0, 0 },
217   { "peephole2", 'z', 1, 0, 0 },
218   { "ce3",      'E', 1, 0, 0 },
219   { "rnreg",    'n', 1, 0, 0 },
220   { "bbro",     'B', 1, 0, 0 },
221   { "btl",      'd', 1, 0, 0 }, /* Yes, duplicate enable switch.  */
222   { "sched2",   'R', 1, 0, 0 },
223   { "stack",    'k', 1, 0, 0 },
224   { "vartrack", 'V', 1, 0, 0 }, /* Yes, duplicate enable switch.  */
225   { "mach",     'M', 1, 0, 0 },
226   { "dbr",      'd', 0, 0, 0 },
227 };
228
229 /* Routine to open a dump file.  Return true if the dump file is enabled.  */
230
231 static int
232 open_dump_file (enum dump_file_index index, tree decl)
233 {
234   char *dump_name;
235   const char *open_arg;
236   char seq[16];
237
238   if (! dump_file_tbl[index].enabled)
239     return 0;
240
241   timevar_push (TV_DUMP);
242   if (dump_file != NULL)
243     fclose (dump_file);
244
245   sprintf (seq, DUMPFILE_FORMAT, index);
246
247   if (! dump_file_tbl[index].initialized)
248     {
249       /* If we've not initialized the files, do so now.  */
250       if (graph_dump_format != no_graph
251           && dump_file_tbl[index].graph_dump_p)
252         {
253           dump_name = concat (seq, dump_file_tbl[index].extension, NULL);
254           clean_graph_dump_file (dump_base_name, dump_name);
255           free (dump_name);
256         }
257       dump_file_tbl[index].initialized = 1;
258       open_arg = "w";
259     }
260   else
261     open_arg = "a";
262
263   dump_name = concat (dump_base_name, seq,
264                       dump_file_tbl[index].extension, NULL);
265
266   dump_file = fopen (dump_name, open_arg);
267   if (dump_file == NULL)
268     fatal_error ("can't open %s: %m", dump_name);
269
270   free (dump_name);
271
272   if (decl)
273     fprintf (dump_file, "\n;; Function %s%s\n\n",
274              lang_hooks.decl_printable_name (decl, 2),
275              cfun->function_frequency == FUNCTION_FREQUENCY_HOT
276              ? " (hot)"
277              : cfun->function_frequency == FUNCTION_FREQUENCY_UNLIKELY_EXECUTED
278              ? " (unlikely executed)"
279              : "");
280
281   timevar_pop (TV_DUMP);
282   return 1;
283 }
284
285 /* Routine to close a dump file.  */
286
287 static void
288 close_dump_file (enum dump_file_index index,
289                  void (*func) (FILE *, rtx),
290                  rtx insns)
291 {
292   if (! dump_file)
293     return;
294
295   timevar_push (TV_DUMP);
296   if (insns
297       && graph_dump_format != no_graph
298       && dump_file_tbl[index].graph_dump_p)
299     {
300       char seq[16];
301       char *suffix;
302
303       sprintf (seq, DUMPFILE_FORMAT, index);
304       suffix = concat (seq, dump_file_tbl[index].extension, NULL);
305       print_rtl_graph_with_bb (dump_base_name, suffix, insns);
306       free (suffix);
307     }
308
309   if (func && insns)
310     func (dump_file, insns);
311
312   fflush (dump_file);
313   fclose (dump_file);
314
315   dump_file = NULL;
316   timevar_pop (TV_DUMP);
317 }
318
319 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
320    and TYPE_DECL nodes.
321
322    This does nothing for local (non-static) variables, unless the
323    variable is a register variable with an ASMSPEC.  In that case, or
324    if the variable is not an automatic, it sets up the RTL and
325    outputs any assembler code (label definition, storage allocation
326    and initialization).
327
328    DECL is the declaration.  If ASMSPEC is nonzero, it specifies
329    the assembler symbol name to be used.  TOP_LEVEL is nonzero
330    if this declaration is not within a function.  */
331
332 void
333 rest_of_decl_compilation (tree decl,
334                           const char *asmspec,
335                           int top_level,
336                           int at_end)
337 {
338   /* We deferred calling assemble_alias so that we could collect
339      other attributes such as visibility.  Emit the alias now.  */
340   {
341     tree alias;
342     alias = lookup_attribute ("alias", DECL_ATTRIBUTES (decl));
343     if (alias)
344       {
345         alias = TREE_VALUE (TREE_VALUE (alias));
346         alias = get_identifier (TREE_STRING_POINTER (alias));
347         assemble_alias (decl, alias);
348       }
349   }
350
351   /* Forward declarations for nested functions are not "external",
352      but we need to treat them as if they were.  */
353   if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
354       || TREE_CODE (decl) == FUNCTION_DECL)
355     {
356       timevar_push (TV_VARCONST);
357
358       if (asmspec)
359         make_decl_rtl (decl, asmspec);
360
361       /* Don't output anything when a tentative file-scope definition
362          is seen.  But at end of compilation, do output code for them.
363
364          We do output all variables when unit-at-a-time is active and rely on
365          callgraph code to defer them except for forward declarations
366          (see gcc.c-torture/compile/920624-1.c) */
367       if ((at_end
368            || !DECL_DEFER_OUTPUT (decl)
369            || (flag_unit_at_a_time && DECL_INITIAL (decl)))
370           && !DECL_EXTERNAL (decl))
371         {
372           if (flag_unit_at_a_time && !cgraph_global_info_ready
373               && TREE_CODE (decl) != FUNCTION_DECL && top_level
374               /* If we defer processing of decls that have had their
375                  DECL_RTL set above (say, in make_decl_rtl),
376                  check_global_declarations() will clear it before
377                  assemble_variable has a chance to act on it.  This
378                  would remove all traces of the register name in a
379                  global register variable, for example.  */
380               && !DECL_RTL_SET_P (decl))
381             cgraph_varpool_finalize_decl (decl);
382           else
383             assemble_variable (decl, top_level, at_end, 0);
384         }
385
386 #ifdef ASM_FINISH_DECLARE_OBJECT
387       if (decl == last_assemble_variable_decl)
388         {
389           ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
390                                      top_level, at_end);
391         }
392 #endif
393
394       timevar_pop (TV_VARCONST);
395     }
396   else if (DECL_REGISTER (decl) && asmspec != 0)
397     {
398       if (decode_reg_name (asmspec) >= 0)
399         {
400           SET_DECL_RTL (decl, NULL_RTX);
401           make_decl_rtl (decl, asmspec);
402         }
403       else
404         {
405           error ("%Hinvalid register name `%s' for register variable",
406                  &DECL_SOURCE_LOCATION (decl), asmspec);
407           DECL_REGISTER (decl) = 0;
408           if (!top_level)
409             expand_decl (decl);
410         }
411     }
412   else if (TREE_CODE (decl) == TYPE_DECL)
413     {
414       timevar_push (TV_SYMOUT);
415       debug_hooks->type_decl (decl, !top_level);
416       timevar_pop (TV_SYMOUT);
417     }
418 }
419
420 /* Called after finishing a record, union or enumeral type.  */
421
422 void
423 rest_of_type_compilation (tree type, int toplev)
424 {
425   /* Avoid confusing the debug information machinery when there are
426      errors.  */
427   if (errorcount != 0 || sorrycount != 0)
428     return;
429
430   timevar_push (TV_SYMOUT);
431   debug_hooks->type_decl (TYPE_STUB_DECL (type), !toplev);
432   timevar_pop (TV_SYMOUT);
433 }
434
435 /* Turn the RTL into assembly.  */
436 static void
437 rest_of_handle_final (void)
438 {
439   timevar_push (TV_FINAL);
440   {
441     rtx x;
442     const char *fnname;
443
444     /* Get the function's name, as described by its RTL.  This may be
445        different from the DECL_NAME name used in the source file.  */
446
447     x = DECL_RTL (current_function_decl);
448     if (!MEM_P (x))
449       abort ();
450     x = XEXP (x, 0);
451     if (GET_CODE (x) != SYMBOL_REF)
452       abort ();
453     fnname = XSTR (x, 0);
454
455     assemble_start_function (current_function_decl, fnname);
456     final_start_function (get_insns (), asm_out_file, optimize);
457     final (get_insns (), asm_out_file, optimize, 0);
458     final_end_function ();
459
460 #ifdef TARGET_UNWIND_INFO
461     /* ??? The IA-64 ".handlerdata" directive must be issued before
462        the ".endp" directive that closes the procedure descriptor.  */
463     output_function_exception_table ();
464 #endif
465
466     assemble_end_function (current_function_decl, fnname);
467
468 #ifndef TARGET_UNWIND_INFO
469     /* Otherwise, it feels unclean to switch sections in the middle.  */
470     output_function_exception_table ();
471 #endif
472
473     if (! quiet_flag)
474       fflush (asm_out_file);
475
476     /* Release all memory allocated by flow.  */
477     free_basic_block_vars ();
478
479     /* Release all memory held by regsets now.  */
480     regset_release_memory ();
481   }
482
483   /* Write DBX symbols if requested.  */
484
485   /* Note that for those inline functions where we don't initially
486      know for certain that we will be generating an out-of-line copy,
487      the first invocation of this routine (rest_of_compilation) will
488      skip over this code by doing a `goto exit_rest_of_compilation;'.
489      Later on, wrapup_global_declarations will (indirectly) call
490      rest_of_compilation again for those inline functions that need
491      to have out-of-line copies generated.  During that call, we
492      *will* be routed past here.  */
493
494   timevar_push (TV_SYMOUT);
495   (*debug_hooks->function_decl) (current_function_decl);
496   timevar_pop (TV_SYMOUT);
497
498   ggc_collect ();
499   timevar_pop (TV_FINAL);
500 }
501
502 #ifdef DELAY_SLOTS
503 /* Run delay slot optimization.  */
504 static void
505 rest_of_handle_delay_slots (void)
506 {
507   timevar_push (TV_DBR_SCHED);
508   open_dump_file (DFI_dbr, current_function_decl);
509
510   dbr_schedule (get_insns (), dump_file);
511
512   close_dump_file (DFI_dbr, print_rtl, get_insns ());
513
514   ggc_collect ();
515
516   timevar_pop (TV_DBR_SCHED);
517 }
518 #endif
519
520 #ifdef STACK_REGS
521 /* Convert register usage from flat register file usage to a stack
522    register file.  */
523 static void
524 rest_of_handle_stack_regs (void)
525 {
526 #if defined (HAVE_ATTR_length)
527   /* If flow2 creates new instructions which need splitting
528      and scheduling after reload is not done, they might not be
529      split until final which doesn't allow splitting
530      if HAVE_ATTR_length.  */
531 #ifdef INSN_SCHEDULING
532   if (optimize && !flag_schedule_insns_after_reload)
533 #else
534   if (optimize)
535 #endif
536     {
537       timevar_push (TV_SHORTEN_BRANCH);
538       split_all_insns (1);
539       timevar_pop (TV_SHORTEN_BRANCH);
540     }
541 #endif
542
543   timevar_push (TV_REG_STACK);
544   open_dump_file (DFI_stack, current_function_decl);
545
546   if (reg_to_stack (dump_file) && optimize)
547     {
548       if (cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK
549                        | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0))
550           && (flag_reorder_blocks || flag_reorder_blocks_and_partition))
551         {
552           reorder_basic_blocks ();
553           cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK);
554         }
555     }
556
557   close_dump_file (DFI_stack, print_rtl_with_bb, get_insns ());
558
559   ggc_collect ();
560   timevar_pop (TV_REG_STACK);
561 }
562 #endif
563
564 /* Track the variables, ie. compute where the variable is stored at each position in function.  */
565 static void
566 rest_of_handle_variable_tracking (void)
567 {
568   timevar_push (TV_VAR_TRACKING);
569   open_dump_file (DFI_vartrack, current_function_decl);
570
571   variable_tracking_main ();
572
573   close_dump_file (DFI_vartrack, print_rtl_with_bb, get_insns ());
574   timevar_pop (TV_VAR_TRACKING);
575 }
576
577 /* Machine dependent reorg pass.  */
578 static void
579 rest_of_handle_machine_reorg (void)
580 {
581   timevar_push (TV_MACH_DEP);
582   open_dump_file (DFI_mach, current_function_decl);
583
584   targetm.machine_dependent_reorg ();
585
586   close_dump_file (DFI_mach, print_rtl, get_insns ());
587
588   ggc_collect ();
589   timevar_pop (TV_MACH_DEP);
590 }
591
592
593 /* Run new register allocator.  Return TRUE if we must exit
594    rest_of_compilation upon return.  */
595 static bool
596 rest_of_handle_new_regalloc (void)
597 {
598   int failure;
599
600   timevar_push (TV_LOCAL_ALLOC);
601   open_dump_file (DFI_lreg, current_function_decl);
602
603   delete_trivially_dead_insns (get_insns (), max_reg_num ());
604   reg_alloc ();
605
606   timevar_pop (TV_LOCAL_ALLOC);
607   close_dump_file (DFI_lreg, NULL, NULL);
608
609   /* XXX clean up the whole mess to bring live info in shape again.  */
610   timevar_push (TV_GLOBAL_ALLOC);
611   open_dump_file (DFI_greg, current_function_decl);
612
613   build_insn_chain (get_insns ());
614   failure = reload (get_insns (), 0);
615
616   timevar_pop (TV_GLOBAL_ALLOC);
617
618   ggc_collect ();
619
620   if (dump_file_tbl[DFI_greg].enabled)
621     {
622       timevar_push (TV_DUMP);
623       dump_global_regs (dump_file);
624       timevar_pop (TV_DUMP);
625       close_dump_file (DFI_greg, print_rtl_with_bb, get_insns ());
626     }
627
628   if (failure)
629     return true;
630
631   reload_completed = 1;
632
633   return false;
634 }
635
636 /* Run old register allocator.  Return TRUE if we must exit
637    rest_of_compilation upon return.  */
638 static bool
639 rest_of_handle_old_regalloc (void)
640 {
641   int failure;
642   int rebuild_notes;
643
644   timevar_push (TV_LOCAL_ALLOC);
645   open_dump_file (DFI_lreg, current_function_decl);
646
647   /* Allocate the reg_renumber array.  */
648   allocate_reg_info (max_regno, FALSE, TRUE);
649
650   /* And the reg_equiv_memory_loc array.  */
651   VARRAY_GROW (reg_equiv_memory_loc_varray, max_regno);
652   reg_equiv_memory_loc = &VARRAY_RTX (reg_equiv_memory_loc_varray, 0);
653
654   allocate_initial_values (reg_equiv_memory_loc);
655
656   regclass (get_insns (), max_reg_num (), dump_file);
657   rebuild_notes = local_alloc ();
658
659   timevar_pop (TV_LOCAL_ALLOC);
660
661   /* Local allocation may have turned an indirect jump into a direct
662      jump.  If so, we must rebuild the JUMP_LABEL fields of jumping
663      instructions.  */
664   if (rebuild_notes)
665     {
666       timevar_push (TV_JUMP);
667
668       rebuild_jump_labels (get_insns ());
669       purge_all_dead_edges (0);
670
671       timevar_pop (TV_JUMP);
672     }
673
674   if (dump_file_tbl[DFI_lreg].enabled)
675     {
676       timevar_push (TV_DUMP);
677       dump_flow_info (dump_file);
678       dump_local_alloc (dump_file);
679       timevar_pop (TV_DUMP);
680     }
681
682   close_dump_file (DFI_lreg, print_rtl_with_bb, get_insns ());
683
684   ggc_collect ();
685
686   timevar_push (TV_GLOBAL_ALLOC);
687   open_dump_file (DFI_greg, current_function_decl);
688
689   /* If optimizing, allocate remaining pseudo-regs.  Do the reload
690      pass fixing up any insns that are invalid.  */
691
692   if (optimize)
693     failure = global_alloc (dump_file);
694   else
695     {
696       build_insn_chain (get_insns ());
697       failure = reload (get_insns (), 0);
698     }
699
700   if (dump_file_tbl[DFI_greg].enabled)
701     {
702       timevar_push (TV_DUMP);
703       dump_global_regs (dump_file);
704       timevar_pop (TV_DUMP);
705
706       close_dump_file (DFI_greg, print_rtl_with_bb, get_insns ());
707     }
708
709   ggc_collect ();
710
711   timevar_pop (TV_GLOBAL_ALLOC);
712
713   return failure;
714 }
715
716 /* Run the regrename and cprop passes.  */
717 static void
718 rest_of_handle_regrename (void)
719 {
720   timevar_push (TV_RENAME_REGISTERS);
721   open_dump_file (DFI_rnreg, current_function_decl);
722
723   if (flag_rename_registers)
724     regrename_optimize ();
725   if (flag_cprop_registers)
726     copyprop_hardreg_forward ();
727
728   close_dump_file (DFI_rnreg, print_rtl_with_bb, get_insns ());
729   timevar_pop (TV_RENAME_REGISTERS);
730 }
731
732 /* Reorder basic blocks.  */
733 static void
734 rest_of_handle_reorder_blocks (void)
735 {
736   bool changed;
737   open_dump_file (DFI_bbro, current_function_decl);
738
739   /* Last attempt to optimize CFG, as scheduling, peepholing and insn
740      splitting possibly introduced more crossjumping opportunities.  */
741   changed = cleanup_cfg (CLEANUP_EXPENSIVE
742                          | (!HAVE_conditional_execution
743                             ? CLEANUP_UPDATE_LIFE : 0));
744
745   if (flag_sched2_use_traces && flag_schedule_insns_after_reload)
746     tracer ();
747   if (flag_reorder_blocks || flag_reorder_blocks_and_partition)
748     reorder_basic_blocks ();
749   if (flag_reorder_blocks || flag_reorder_blocks_and_partition
750       || (flag_sched2_use_traces && flag_schedule_insns_after_reload))
751     changed |= cleanup_cfg (CLEANUP_EXPENSIVE
752                             | (!HAVE_conditional_execution
753                                ? CLEANUP_UPDATE_LIFE : 0));
754
755   /* On conditional execution targets we can not update the life cheaply, so
756      we deffer the updating to after both cleanups.  This may lose some cases
757      but should not be terribly bad.  */
758   if (changed && HAVE_conditional_execution)
759     update_life_info (NULL, UPDATE_LIFE_GLOBAL_RM_NOTES,
760                       PROP_DEATH_NOTES);
761   close_dump_file (DFI_bbro, print_rtl_with_bb, get_insns ());
762 }
763
764 /* Partition hot and cold basic blocks.  */
765 static void
766 rest_of_handle_partition_blocks (void)
767 {
768   no_new_pseudos = 0;
769   partition_hot_cold_basic_blocks ();
770   allocate_reg_life_data ();
771   update_life_info (NULL, UPDATE_LIFE_GLOBAL_RM_NOTES, 
772                     PROP_LOG_LINKS | PROP_REG_INFO | PROP_DEATH_NOTES);
773   no_new_pseudos = 1;
774 }
775
776 #ifdef INSN_SCHEDULING
777 /* Run instruction scheduler.  */
778 /* Perform SMS module scheduling.  */
779 static void
780 rest_of_handle_sms (void)
781 {
782   timevar_push (TV_SMS);
783   open_dump_file (DFI_sms, current_function_decl);
784
785   /* We want to be able to create new pseudos.  */
786   no_new_pseudos = 0;
787   sms_schedule (dump_file);
788   close_dump_file (DFI_sms, print_rtl, get_insns ());
789
790
791   /* Update the life information, because we add pseudos.  */
792   max_regno = max_reg_num ();
793   allocate_reg_info (max_regno, FALSE, FALSE);
794   update_life_info_in_dirty_blocks (UPDATE_LIFE_GLOBAL_RM_NOTES,
795                                     (PROP_DEATH_NOTES
796                                      | PROP_KILL_DEAD_CODE
797                                      | PROP_SCAN_DEAD_CODE));
798   no_new_pseudos = 1;
799
800   ggc_collect ();
801   timevar_pop (TV_SMS);
802 }
803
804 /* Run instruction scheduler.  */
805 static void
806 rest_of_handle_sched (void)
807 {
808   timevar_push (TV_SCHED);
809
810   /* Print function header into sched dump now
811      because doing the sched analysis makes some of the dump.  */
812   open_dump_file (DFI_sched, current_function_decl);
813
814   /* Do control and data sched analysis,
815      and write some of the results to dump file.  */
816
817   schedule_insns (dump_file);
818
819   close_dump_file (DFI_sched, print_rtl_with_bb, get_insns ());
820
821   ggc_collect ();
822   timevar_pop (TV_SCHED);
823 }
824
825 /* Run second scheduling pass after reload.  */
826 static void
827 rest_of_handle_sched2 (void)
828 {
829   timevar_push (TV_SCHED2);
830   open_dump_file (DFI_sched2, current_function_decl);
831
832   /* Do control and data sched analysis again,
833      and write some more of the results to dump file.  */
834
835   split_all_insns (1);
836
837   if (flag_sched2_use_superblocks || flag_sched2_use_traces)
838     {
839       schedule_ebbs (dump_file);
840       /* No liveness updating code yet, but it should be easy to do.
841          reg-stack recomputes the liveness when needed for now.  */
842       count_or_remove_death_notes (NULL, 1);
843       cleanup_cfg (CLEANUP_EXPENSIVE);
844     }
845   else
846     schedule_insns (dump_file);
847
848   close_dump_file (DFI_sched2, print_rtl_with_bb, get_insns ());
849
850   ggc_collect ();
851
852   timevar_pop (TV_SCHED2);
853 }
854 #endif
855
856 static void
857 rest_of_handle_gcse2 (void)
858 {
859   timevar_push (TV_RELOAD_CSE_REGS);
860   open_dump_file (DFI_gcse2, current_function_decl);
861
862   gcse_after_reload_main (get_insns (), dump_file);
863   rebuild_jump_labels (get_insns ());
864   delete_trivially_dead_insns (get_insns (), max_reg_num ());
865   close_dump_file (DFI_gcse2, print_rtl_with_bb, get_insns ());
866
867   ggc_collect ();
868
869 #ifdef ENABLE_CHECKING
870   verify_flow_info ();
871 #endif
872
873   timevar_pop (TV_RELOAD_CSE_REGS);
874 }
875
876 /* Register allocation pre-pass, to reduce number of moves necessary
877    for two-address machines.  */
878 static void
879 rest_of_handle_regmove (void)
880 {
881   timevar_push (TV_REGMOVE);
882   open_dump_file (DFI_regmove, current_function_decl);
883
884   regmove_optimize (get_insns (), max_reg_num (), dump_file);
885
886   cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
887   close_dump_file (DFI_regmove, print_rtl_with_bb, get_insns ());
888
889   ggc_collect ();
890   timevar_pop (TV_REGMOVE);
891 }
892
893 /* Run tracer.  */
894 static void
895 rest_of_handle_tracer (void)
896 {
897   open_dump_file (DFI_tracer, current_function_decl);
898   if (dump_file)
899     dump_flow_info (dump_file);
900   tracer ();
901   cleanup_cfg (CLEANUP_EXPENSIVE);
902   reg_scan (get_insns (), max_reg_num (), 0);
903   close_dump_file (DFI_tracer, print_rtl_with_bb, get_insns ());
904 }
905
906 /* If-conversion and CFG cleanup.  */
907 static void
908 rest_of_handle_if_conversion (void)
909 {
910   timevar_push (TV_IFCVT);
911   open_dump_file (DFI_ce1, current_function_decl);
912
913   if (flag_if_conversion)
914     {
915       if (dump_file)
916         dump_flow_info (dump_file);
917       cleanup_cfg (CLEANUP_EXPENSIVE);
918       reg_scan (get_insns (), max_reg_num (), 0);
919       if_convert (0);
920     }
921
922   timevar_push (TV_JUMP);
923   cleanup_cfg (CLEANUP_EXPENSIVE);
924   reg_scan (get_insns (), max_reg_num (), 0);
925   timevar_pop (TV_JUMP);
926
927   close_dump_file (DFI_ce1, print_rtl_with_bb, get_insns ());
928   timevar_pop (TV_IFCVT);
929 }
930
931 /* Rerun if-conversion, as combine may have simplified things enough
932    to now meet sequence length restrictions.  */
933 static void
934 rest_of_handle_if_after_combine (void)
935 {
936   timevar_push (TV_IFCVT);
937   open_dump_file (DFI_ce2, current_function_decl);
938
939   no_new_pseudos = 0;
940   if_convert (1);
941   no_new_pseudos = 1;
942
943   close_dump_file (DFI_ce2, print_rtl_with_bb, get_insns ());
944   timevar_pop (TV_IFCVT);
945 }
946
947 static void
948 rest_of_handle_if_after_reload (void)
949 {
950   timevar_push (TV_IFCVT2);
951   open_dump_file (DFI_ce3, current_function_decl);
952
953   /* Last attempt to optimize CFG, as scheduling, peepholing and insn
954      splitting possibly introduced more crossjumping opportunities.  */
955   cleanup_cfg (CLEANUP_EXPENSIVE
956                | CLEANUP_UPDATE_LIFE 
957                | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0));
958   if (flag_if_conversion2)
959     if_convert (1);
960   close_dump_file (DFI_ce3, print_rtl_with_bb, get_insns ());
961   timevar_pop (TV_IFCVT2);
962 }
963
964 static void
965 rest_of_handle_web (void)
966 {
967   open_dump_file (DFI_web, current_function_decl);
968   timevar_push (TV_WEB);
969   web_main ();
970   delete_trivially_dead_insns (get_insns (), max_reg_num ());
971   cleanup_cfg (CLEANUP_EXPENSIVE);
972
973   timevar_pop (TV_WEB);
974   close_dump_file (DFI_web, print_rtl_with_bb, get_insns ());
975   reg_scan (get_insns (), max_reg_num (), 0);
976 }
977
978 /* Do branch profiling and static profile estimation passes.  */
979 static void
980 rest_of_handle_branch_prob (void)
981 {
982   struct loops loops;
983
984   timevar_push (TV_BRANCH_PROB);
985   open_dump_file (DFI_bp, current_function_decl);
986
987   if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
988     branch_prob ();
989
990   /* Discover and record the loop depth at the head of each basic
991      block.  The loop infrastructure does the real job for us.  */
992   flow_loops_find (&loops, LOOP_TREE);
993
994   if (dump_file)
995     flow_loops_dump (&loops, dump_file, NULL, 0);
996
997   /* Estimate using heuristics if no profiling info is available.  */
998   if (flag_guess_branch_prob)
999     estimate_probability (&loops);
1000
1001   flow_loops_free (&loops);
1002   free_dominance_info (CDI_DOMINATORS);
1003   close_dump_file (DFI_bp, print_rtl_with_bb, get_insns ());
1004   timevar_pop (TV_BRANCH_PROB);
1005 }
1006
1007 /* Do optimizations based on expression value profiles.  */
1008 static void
1009 rest_of_handle_value_profile_transformations (void)
1010 {
1011   open_dump_file (DFI_vpt, current_function_decl);
1012   timevar_push (TV_VPT);
1013
1014   if (value_profile_transformations ())
1015     cleanup_cfg (CLEANUP_EXPENSIVE);
1016
1017   timevar_pop (TV_VPT);
1018   close_dump_file (DFI_vpt, print_rtl_with_bb, get_insns ());
1019 }
1020
1021 /* Do control and data flow analysis; write some of the results to the
1022    dump file.  */
1023 static void
1024 rest_of_handle_cfg (void)
1025 {
1026   open_dump_file (DFI_cfg, current_function_decl);
1027   if (dump_file)
1028     dump_flow_info (dump_file);
1029   if (optimize)
1030     cleanup_cfg (CLEANUP_EXPENSIVE
1031                  | (flag_thread_jumps ? CLEANUP_THREADING : 0));
1032
1033   /* It may make more sense to mark constant functions after dead code is
1034      eliminated by life_analysis, but we need to do it early, as -fprofile-arcs
1035      may insert code making function non-constant, but we still must consider
1036      it as constant, otherwise -fbranch-probabilities will not read data back.
1037
1038      life_analysis rarely eliminates modification of external memory.
1039    */
1040   if (optimize)
1041     {
1042       /* Alias analysis depends on this information and mark_constant_function
1043        depends on alias analysis.  */
1044       reg_scan (get_insns (), max_reg_num (), 1);
1045       mark_constant_function ();
1046     }
1047
1048   close_dump_file (DFI_cfg, print_rtl_with_bb, get_insns ());
1049 }
1050
1051 /* Perform jump bypassing and control flow optimizations.  */
1052 static void
1053 rest_of_handle_jump_bypass (void)
1054 {
1055   timevar_push (TV_BYPASS);
1056   open_dump_file (DFI_bypass, current_function_decl);
1057
1058   cleanup_cfg (CLEANUP_EXPENSIVE);
1059   reg_scan (get_insns (), max_reg_num (), 1);
1060
1061   if (bypass_jumps (dump_file))
1062     {
1063       rebuild_jump_labels (get_insns ());
1064       cleanup_cfg (CLEANUP_EXPENSIVE);
1065       delete_trivially_dead_insns (get_insns (), max_reg_num ());
1066     }
1067
1068   close_dump_file (DFI_bypass, print_rtl_with_bb, get_insns ());
1069   timevar_pop (TV_BYPASS);
1070
1071   ggc_collect ();
1072
1073 #ifdef ENABLE_CHECKING
1074   verify_flow_info ();
1075 #endif
1076 }
1077
1078 /* Try combining insns through substitution.  */
1079 static void
1080 rest_of_handle_combine (void)
1081 {
1082   int rebuild_jump_labels_after_combine = 0;
1083
1084   timevar_push (TV_COMBINE);
1085   open_dump_file (DFI_combine, current_function_decl);
1086
1087   rebuild_jump_labels_after_combine
1088     = combine_instructions (get_insns (), max_reg_num ());
1089
1090   /* Combining insns may have turned an indirect jump into a
1091      direct jump.  Rebuild the JUMP_LABEL fields of jumping
1092      instructions.  */
1093   if (rebuild_jump_labels_after_combine)
1094     {
1095       timevar_push (TV_JUMP);
1096       rebuild_jump_labels (get_insns ());
1097       timevar_pop (TV_JUMP);
1098
1099       cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
1100     }
1101
1102   close_dump_file (DFI_combine, print_rtl_with_bb, get_insns ());
1103   timevar_pop (TV_COMBINE);
1104
1105   ggc_collect ();
1106 }
1107
1108 /* Perform life analysis.  */
1109 static void
1110 rest_of_handle_life (void)
1111 {
1112   open_dump_file (DFI_life, current_function_decl);
1113   regclass_init ();
1114
1115 #ifdef ENABLE_CHECKING
1116   verify_flow_info ();
1117 #endif
1118   life_analysis (dump_file, PROP_FINAL);
1119   if (optimize)
1120     cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0) | CLEANUP_UPDATE_LIFE
1121                  | CLEANUP_LOG_LINKS
1122                  | (flag_thread_jumps ? CLEANUP_THREADING : 0));
1123
1124   if (extra_warnings)
1125     {
1126       setjmp_vars_warning (DECL_INITIAL (current_function_decl));
1127       setjmp_args_warning ();
1128     }
1129
1130   if (optimize)
1131     {
1132       if (!flag_new_regalloc && initialize_uninitialized_subregs ())
1133         {
1134           /* Insns were inserted, and possibly pseudos created, so
1135              things might look a bit different.  */
1136           allocate_reg_life_data ();
1137           update_life_info (NULL, UPDATE_LIFE_GLOBAL_RM_NOTES,
1138                             PROP_LOG_LINKS | PROP_REG_INFO | PROP_DEATH_NOTES);
1139         }
1140     }
1141
1142   no_new_pseudos = 1;
1143
1144   close_dump_file (DFI_life, print_rtl_with_bb, get_insns ());
1145
1146   ggc_collect ();
1147 }
1148
1149 /* Perform common subexpression elimination.  Nonzero value from
1150    `cse_main' means that jumps were simplified and some code may now
1151    be unreachable, so do jump optimization again.  */
1152 static void
1153 rest_of_handle_cse (void)
1154 {
1155   int tem;
1156
1157   open_dump_file (DFI_cse, current_function_decl);
1158   if (dump_file)
1159     dump_flow_info (dump_file);
1160   timevar_push (TV_CSE);
1161
1162   reg_scan (get_insns (), max_reg_num (), 1);
1163
1164   tem = cse_main (get_insns (), max_reg_num (), 0, dump_file);
1165   if (tem)
1166     rebuild_jump_labels (get_insns ());
1167   if (purge_all_dead_edges (0))
1168     delete_unreachable_blocks ();
1169
1170   delete_trivially_dead_insns (get_insns (), max_reg_num ());
1171
1172   /* If we are not running more CSE passes, then we are no longer
1173      expecting CSE to be run.  But always rerun it in a cheap mode.  */
1174   cse_not_expected = !flag_rerun_cse_after_loop && !flag_gcse;
1175
1176   if (tem || optimize > 1)
1177     cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
1178
1179   timevar_pop (TV_CSE);
1180   close_dump_file (DFI_cse, print_rtl_with_bb, get_insns ());
1181
1182   ggc_collect ();
1183 }
1184
1185 /* Run second CSE pass after loop optimizations.  */
1186 static void
1187 rest_of_handle_cse2 (void)
1188 {
1189   int tem;
1190
1191   timevar_push (TV_CSE2);
1192   open_dump_file (DFI_cse2, current_function_decl);
1193   if (dump_file)
1194     dump_flow_info (dump_file);
1195   /* CFG is no longer maintained up-to-date.  */
1196   tem = cse_main (get_insns (), max_reg_num (), 1, dump_file);
1197
1198   /* Run a pass to eliminate duplicated assignments to condition code
1199      registers.  We have to run this after bypass_jumps, because it
1200      makes it harder for that pass to determine whether a jump can be
1201      bypassed safely.  */
1202   cse_condition_code_reg ();
1203
1204   purge_all_dead_edges (0);
1205   delete_trivially_dead_insns (get_insns (), max_reg_num ());
1206
1207   if (tem)
1208     {
1209       timevar_push (TV_JUMP);
1210       rebuild_jump_labels (get_insns ());
1211       cleanup_cfg (CLEANUP_EXPENSIVE);
1212       timevar_pop (TV_JUMP);
1213     }
1214   reg_scan (get_insns (), max_reg_num (), 0);
1215   close_dump_file (DFI_cse2, print_rtl_with_bb, get_insns ());
1216   timevar_pop (TV_CSE2);
1217
1218   ggc_collect ();
1219 }
1220
1221 /* Perform global cse.  */
1222 static void
1223 rest_of_handle_gcse (void)
1224 {
1225   int save_csb, save_cfj;
1226   int tem2 = 0, tem;
1227
1228   timevar_push (TV_GCSE);
1229   open_dump_file (DFI_gcse, current_function_decl);
1230
1231   tem = gcse_main (get_insns (), dump_file);
1232   rebuild_jump_labels (get_insns ());
1233   delete_trivially_dead_insns (get_insns (), max_reg_num ());
1234
1235   save_csb = flag_cse_skip_blocks;
1236   save_cfj = flag_cse_follow_jumps;
1237   flag_cse_skip_blocks = flag_cse_follow_jumps = 0;
1238
1239   /* If -fexpensive-optimizations, re-run CSE to clean up things done
1240      by gcse.  */
1241   if (flag_expensive_optimizations)
1242     {
1243       timevar_push (TV_CSE);
1244       reg_scan (get_insns (), max_reg_num (), 1);
1245       tem2 = cse_main (get_insns (), max_reg_num (), 0, dump_file);
1246       purge_all_dead_edges (0);
1247       delete_trivially_dead_insns (get_insns (), max_reg_num ());
1248       timevar_pop (TV_CSE);
1249       cse_not_expected = !flag_rerun_cse_after_loop;
1250     }
1251
1252   /* If gcse or cse altered any jumps, rerun jump optimizations to clean
1253      things up.  Then possibly re-run CSE again.  */
1254   while (tem || tem2)
1255     {
1256       tem = tem2 = 0;
1257       timevar_push (TV_JUMP);
1258       rebuild_jump_labels (get_insns ());
1259       cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
1260       timevar_pop (TV_JUMP);
1261
1262       if (flag_expensive_optimizations)
1263         {
1264           timevar_push (TV_CSE);
1265           reg_scan (get_insns (), max_reg_num (), 1);
1266           tem2 = cse_main (get_insns (), max_reg_num (), 0, dump_file);
1267           purge_all_dead_edges (0);
1268           delete_trivially_dead_insns (get_insns (), max_reg_num ());
1269           timevar_pop (TV_CSE);
1270         }
1271     }
1272
1273   close_dump_file (DFI_gcse, print_rtl_with_bb, get_insns ());
1274   timevar_pop (TV_GCSE);
1275
1276   ggc_collect ();
1277   flag_cse_skip_blocks = save_csb;
1278   flag_cse_follow_jumps = save_cfj;
1279 #ifdef ENABLE_CHECKING
1280   verify_flow_info ();
1281 #endif
1282 }
1283
1284 /* Move constant computations out of loops.  */
1285 static void
1286 rest_of_handle_loop_optimize (void)
1287 {
1288   int do_unroll, do_prefetch;
1289
1290   timevar_push (TV_LOOP);
1291   delete_dead_jumptables ();
1292   cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
1293   open_dump_file (DFI_loop, current_function_decl);
1294
1295   /* CFG is no longer maintained up-to-date.  */
1296   free_bb_for_insn ();
1297
1298   if (flag_unroll_loops)
1299     do_unroll = LOOP_AUTO_UNROLL;       /* Having two unrollers is useless.  */
1300   else
1301     do_unroll = flag_old_unroll_loops ? LOOP_UNROLL : LOOP_AUTO_UNROLL;
1302   do_prefetch = flag_prefetch_loop_arrays ? LOOP_PREFETCH : 0;
1303
1304   if (flag_rerun_loop_opt)
1305     {
1306       cleanup_barriers ();
1307
1308       /* We only want to perform unrolling once.  */
1309       loop_optimize (get_insns (), dump_file, do_unroll);
1310       do_unroll = 0;
1311
1312       /* The first call to loop_optimize makes some instructions
1313          trivially dead.  We delete those instructions now in the
1314          hope that doing so will make the heuristics in loop work
1315          better and possibly speed up compilation.  */
1316       delete_trivially_dead_insns (get_insns (), max_reg_num ());
1317
1318       /* The regscan pass is currently necessary as the alias
1319          analysis code depends on this information.  */
1320       reg_scan (get_insns (), max_reg_num (), 1);
1321     }
1322   cleanup_barriers ();
1323   loop_optimize (get_insns (), dump_file, do_unroll | do_prefetch);
1324
1325   /* Loop can create trivially dead instructions.  */
1326   delete_trivially_dead_insns (get_insns (), max_reg_num ());
1327   find_basic_blocks (get_insns (), max_reg_num (), dump_file);
1328   close_dump_file (DFI_loop, print_rtl, get_insns ());
1329   timevar_pop (TV_LOOP);
1330
1331   ggc_collect ();
1332 }
1333
1334 /* Perform loop optimizations.  It might be better to do them a bit
1335    sooner, but we want the profile feedback to work more
1336    efficiently.  */
1337 static void
1338 rest_of_handle_loop2 (void)
1339 {
1340   struct loops *loops;
1341   basic_block bb;
1342
1343   if (!flag_move_loop_invariants
1344       && !flag_unswitch_loops
1345       && !flag_peel_loops
1346       && !flag_unroll_loops
1347       && !flag_branch_on_count_reg)
1348     return;
1349
1350   timevar_push (TV_LOOP);
1351   open_dump_file (DFI_loop2, current_function_decl);
1352   if (dump_file)
1353     dump_flow_info (dump_file);
1354
1355   /* Initialize structures for layout changes.  */
1356   cfg_layout_initialize ();
1357
1358   loops = loop_optimizer_init (dump_file);
1359
1360   if (loops)
1361     {
1362       /* The optimizations:  */
1363       if (flag_move_loop_invariants)
1364         move_loop_invariants (loops);
1365
1366       if (flag_unswitch_loops)
1367         unswitch_loops (loops);
1368
1369       if (flag_peel_loops || flag_unroll_loops)
1370         unroll_and_peel_loops (loops,
1371                                (flag_peel_loops ? UAP_PEEL : 0) |
1372                                (flag_unroll_loops ? UAP_UNROLL : 0) |
1373                                (flag_unroll_all_loops ? UAP_UNROLL_ALL : 0));
1374
1375 #ifdef HAVE_doloop_end
1376       if (flag_branch_on_count_reg && HAVE_doloop_end)
1377         doloop_optimize_loops (loops);
1378 #endif /* HAVE_doloop_end */
1379
1380       loop_optimizer_finalize (loops, dump_file);
1381     }
1382
1383   free_dominance_info (CDI_DOMINATORS);
1384
1385   /* Finalize layout changes.  */
1386   FOR_EACH_BB (bb)
1387     if (bb->next_bb != EXIT_BLOCK_PTR)
1388       bb->rbi->next = bb->next_bb;
1389   cfg_layout_finalize ();
1390
1391   cleanup_cfg (CLEANUP_EXPENSIVE);
1392   delete_trivially_dead_insns (get_insns (), max_reg_num ());
1393   reg_scan (get_insns (), max_reg_num (), 0);
1394   if (dump_file)
1395     dump_flow_info (dump_file);
1396   close_dump_file (DFI_loop2, print_rtl_with_bb, get_insns ());
1397   timevar_pop (TV_LOOP);
1398   ggc_collect ();
1399 }
1400
1401 static void
1402 rest_of_handle_branch_target_load_optimize (void)
1403 {
1404   static int warned = 0;
1405
1406   /* Leave this a warning for now so that it is possible to experiment
1407      with running this pass twice.  In 3.6, we should either make this
1408      an error, or use separate dump files.  */
1409   if (flag_branch_target_load_optimize
1410       && flag_branch_target_load_optimize2
1411       && !warned)
1412     {
1413       warning ("branch target register load optimization is not intended "
1414                "to be run twice");
1415
1416       warned = 1;
1417     }
1418
1419   open_dump_file (DFI_branch_target_load, current_function_decl);
1420   branch_target_load_optimize (epilogue_completed);
1421   close_dump_file (DFI_branch_target_load, print_rtl_with_bb, get_insns ());
1422   ggc_collect ();
1423 }
1424
1425 #ifdef OPTIMIZE_MODE_SWITCHING
1426 static void
1427 rest_of_handle_mode_switching (void)
1428 {
1429   timevar_push (TV_MODE_SWITCH);
1430
1431   no_new_pseudos = 0;
1432   optimize_mode_switching (NULL);
1433   no_new_pseudos = 1;
1434
1435   timevar_pop (TV_MODE_SWITCH);
1436 }
1437 #endif
1438
1439 static void
1440 rest_of_handle_jump (void)
1441 {
1442   ggc_collect ();
1443
1444   timevar_push (TV_JUMP);
1445   open_dump_file (DFI_sibling, current_function_decl);
1446
1447   /* ??? We may get caled either via tree_rest_of_compilation when the CFG
1448      is already built or directly (for instance from coverage code).
1449      The direct callers shall be updated.  */
1450   if (!basic_block_info)
1451     {
1452       init_flow ();
1453       rebuild_jump_labels (get_insns ());
1454       find_exception_handler_labels ();
1455       find_basic_blocks (get_insns (), max_reg_num (), dump_file);
1456     }
1457
1458   /* ??? We may get called either via tree_rest_of_compilation when the CFG
1459      is already built or directly (for instance from coverage code).
1460      The direct callers shall be updated.  */
1461   if (!basic_block_info)
1462     {
1463       init_flow ();
1464       rebuild_jump_labels (get_insns ());
1465       find_exception_handler_labels ();
1466       find_basic_blocks (get_insns (), max_reg_num (), dump_file);
1467     }
1468   delete_unreachable_blocks ();
1469 #ifdef ENABLE_CHECKING
1470   verify_flow_info ();
1471 #endif
1472   timevar_pop (TV_JUMP);
1473 }
1474
1475 static void
1476 rest_of_handle_guess_branch_prob (void)
1477 {
1478   /* Turn NOTE_INSN_PREDICTIONs into branch predictions.  */
1479   if (flag_guess_branch_prob)
1480     {
1481       timevar_push (TV_BRANCH_PROB);
1482       note_prediction_to_br_prob ();
1483       timevar_pop (TV_BRANCH_PROB);
1484     }
1485 }
1486
1487 static void
1488 rest_of_handle_eh (void)
1489 {
1490   insn_locators_initialize ();
1491   /* Complete generation of exception handling code.  */
1492   if (doing_eh (0))
1493     {
1494       timevar_push (TV_JUMP);
1495       open_dump_file (DFI_eh, current_function_decl);
1496
1497       finish_eh_generation ();
1498
1499       close_dump_file (DFI_eh, print_rtl, get_insns ());
1500       timevar_pop (TV_JUMP);
1501     }
1502 }
1503
1504
1505 static void
1506 rest_of_handle_prologue_epilogue (void)
1507 {
1508   if (optimize && !flow2_completed)
1509     cleanup_cfg (CLEANUP_EXPENSIVE);
1510
1511   /* On some machines, the prologue and epilogue code, or parts thereof,
1512      can be represented as RTL.  Doing so lets us schedule insns between
1513      it and the rest of the code and also allows delayed branch
1514      scheduling to operate in the epilogue.  */
1515   thread_prologue_and_epilogue_insns (get_insns ());
1516   epilogue_completed = 1;
1517
1518   if (optimize && flow2_completed)
1519     life_analysis (dump_file, PROP_POSTRELOAD);
1520 }
1521
1522 static void
1523 rest_of_handle_stack_adjustments (void)
1524 {
1525   life_analysis (dump_file, PROP_POSTRELOAD);
1526   cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE
1527                | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0));
1528     
1529   /* This is kind of a heuristic.  We need to run combine_stack_adjustments
1530      even for machines with possibly nonzero RETURN_POPS_ARGS
1531      and ACCUMULATE_OUTGOING_ARGS.  We expect that only ports having
1532      push instructions will have popping returns.  */
1533 #ifndef PUSH_ROUNDING
1534   if (!ACCUMULATE_OUTGOING_ARGS)
1535 #endif
1536     combine_stack_adjustments ();
1537 }
1538
1539 static void
1540 rest_of_handle_flow2 (void)
1541 {
1542   timevar_push (TV_FLOW2);
1543   open_dump_file (DFI_flow2, current_function_decl);
1544
1545   /* Re-create the death notes which were deleted during reload.  */
1546 #ifdef ENABLE_CHECKING
1547   verify_flow_info ();
1548 #endif
1549
1550   /* If optimizing, then go ahead and split insns now.  */
1551 #ifndef STACK_REGS
1552   if (optimize > 0)
1553 #endif
1554     split_all_insns (0);
1555
1556   if (flag_branch_target_load_optimize)
1557     rest_of_handle_branch_target_load_optimize ();
1558
1559   if (!targetm.late_rtl_prologue_epilogue)
1560     rest_of_handle_prologue_epilogue ();
1561
1562   if (optimize)
1563     rest_of_handle_stack_adjustments ();
1564
1565   flow2_completed = 1;
1566
1567   close_dump_file (DFI_flow2, print_rtl_with_bb, get_insns ());
1568   timevar_pop (TV_FLOW2);
1569
1570   ggc_collect ();
1571 }
1572
1573
1574 static void
1575 rest_of_handle_jump2 (void)
1576 {
1577   open_dump_file (DFI_jump, current_function_decl);
1578
1579   /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
1580      are initialized and to compute whether control can drop off the end
1581      of the function.  */
1582
1583   timevar_push (TV_JUMP);
1584   /* Turn NOTE_INSN_EXPECTED_VALUE into REG_BR_PROB.  Do this
1585      before jump optimization switches branch directions.  */
1586   if (flag_guess_branch_prob)
1587     expected_value_to_br_prob ();
1588
1589   delete_trivially_dead_insns (get_insns (), max_reg_num ());
1590   reg_scan (get_insns (), max_reg_num (), 0);
1591   if (dump_file)
1592     dump_flow_info (dump_file);
1593   cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0) | CLEANUP_PRE_LOOP
1594                | (flag_thread_jumps ? CLEANUP_THREADING : 0));
1595
1596   create_loop_notes ();
1597
1598   purge_line_number_notes (get_insns ());
1599
1600   if (optimize)
1601     cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
1602
1603   /* Jump optimization, and the removal of NULL pointer checks, may
1604      have reduced the number of instructions substantially.  CSE, and
1605      future passes, allocate arrays whose dimensions involve the
1606      maximum instruction UID, so if we can reduce the maximum UID
1607      we'll save big on memory.  */
1608   renumber_insns (dump_file);
1609
1610   close_dump_file (DFI_jump, print_rtl_with_bb, get_insns ());
1611   timevar_pop (TV_JUMP);
1612
1613   ggc_collect ();
1614 }
1615
1616 #ifdef HAVE_peephole2
1617 static void
1618 rest_of_handle_peephole2 (void)
1619 {
1620   timevar_push (TV_PEEPHOLE2);
1621   open_dump_file (DFI_peephole2, current_function_decl);
1622
1623   peephole2_optimize (dump_file);
1624
1625   close_dump_file (DFI_peephole2, print_rtl_with_bb, get_insns ());
1626   timevar_pop (TV_PEEPHOLE2);
1627 }
1628 #endif
1629
1630 static void
1631 rest_of_handle_postreload (void)
1632 {
1633   timevar_push (TV_RELOAD_CSE_REGS);
1634   open_dump_file (DFI_postreload, current_function_decl);
1635
1636   /* Do a very simple CSE pass over just the hard registers.  */
1637   reload_cse_regs (get_insns ());
1638   /* reload_cse_regs can eliminate potentially-trapping MEMs.
1639      Remove any EH edges associated with them.  */
1640   if (flag_non_call_exceptions)
1641     purge_all_dead_edges (0);
1642
1643   close_dump_file (DFI_postreload, print_rtl_with_bb, get_insns ());
1644   timevar_pop (TV_RELOAD_CSE_REGS);
1645 }
1646
1647 static void
1648 rest_of_handle_shorten_branches (void)
1649 {
1650   /* Shorten branches.  */
1651   timevar_push (TV_SHORTEN_BRANCH);
1652   shorten_branches (get_insns ());
1653   timevar_pop (TV_SHORTEN_BRANCH);
1654 }
1655
1656 static void
1657 rest_of_clean_state (void)
1658 {
1659   coverage_end_function ();
1660
1661   /* In case the function was not output,
1662      don't leave any temporary anonymous types
1663      queued up for sdb output.  */
1664 #ifdef SDB_DEBUGGING_INFO
1665   if (write_symbols == SDB_DEBUG)
1666     sdbout_types (NULL_TREE);
1667 #endif
1668
1669   reload_completed = 0;
1670   epilogue_completed = 0;
1671   flow2_completed = 0;
1672   no_new_pseudos = 0;
1673
1674   timevar_push (TV_FINAL);
1675
1676   /* Clear out the insn_length contents now that they are no
1677      longer valid.  */
1678   init_insn_lengths ();
1679
1680   /* Show no temporary slots allocated.  */
1681   init_temp_slots ();
1682
1683   free_basic_block_vars ();
1684   free_bb_for_insn ();
1685
1686   timevar_pop (TV_FINAL);
1687
1688   if (targetm.binds_local_p (current_function_decl))
1689     {
1690       int pref = cfun->preferred_stack_boundary;
1691       if (cfun->recursive_call_emit
1692           && cfun->stack_alignment_needed > cfun->preferred_stack_boundary)
1693         pref = cfun->stack_alignment_needed;
1694       cgraph_rtl_info (current_function_decl)->preferred_incoming_stack_boundary
1695         = pref;
1696     }
1697
1698   /* Make sure volatile mem refs aren't considered valid operands for
1699      arithmetic insns.  We must call this here if this is a nested inline
1700      function, since the above code leaves us in the init_recog state
1701      (from final.c), and the function context push/pop code does not
1702      save/restore volatile_ok.
1703
1704      ??? Maybe it isn't necessary for expand_start_function to call this
1705      anymore if we do it here?  */
1706
1707   init_recog_no_volatile ();
1708
1709   /* We're done with this function.  Free up memory if we can.  */
1710   free_after_parsing (cfun);
1711 }
1712 \f
1713
1714 /* This is called from finish_function (within langhooks.parse_file)
1715    after each top-level definition is parsed.
1716    It is supposed to compile that function or variable
1717    and output the assembler code for it.
1718    After we return, the tree storage is freed.  */
1719
1720 void
1721 rest_of_compilation (void)
1722 {
1723   /* There's no need to defer outputting this function any more; we
1724      know we want to output it.  */
1725   DECL_DEFER_OUTPUT (current_function_decl) = 0;
1726
1727   /* Register rtl specific functions for cfg.  */
1728   rtl_register_cfg_hooks ();
1729
1730   /* Now that we're out of the frontend, we shouldn't have any more
1731      CONCATs anywhere.  */
1732   generating_concat_p = 0;
1733
1734   /* When processing delayed functions, prepare_function_start () won't
1735      have been run to re-initialize it.  */
1736   cse_not_expected = ! optimize;
1737
1738   finalize_block_changes ();
1739
1740   /* Dump the rtl code if we are dumping rtl.  */
1741   if (open_dump_file (DFI_rtl, current_function_decl))
1742     close_dump_file (DFI_rtl, print_rtl, get_insns ());
1743
1744   /* Convert from NOTE_INSN_EH_REGION style notes, and do other
1745      sorts of eh initialization.  Delay this until after the
1746      initial rtl dump so that we can see the original nesting.  */
1747   convert_from_eh_region_ranges ();
1748
1749   /* If we're emitting a nested function, make sure its parent gets
1750      emitted as well.  Doing otherwise confuses debug info.  */
1751   {
1752     tree parent;
1753     for (parent = DECL_CONTEXT (current_function_decl);
1754          parent != NULL_TREE;
1755          parent = get_containing_scope (parent))
1756       if (TREE_CODE (parent) == FUNCTION_DECL)
1757         TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (parent)) = 1;
1758   }
1759
1760   /* We are now committed to emitting code for this function.  Do any
1761      preparation, such as emitting abstract debug info for the inline
1762      before it gets mangled by optimization.  */
1763   if (cgraph_function_possibly_inlined_p (current_function_decl))
1764     (*debug_hooks->outlining_inline_function) (current_function_decl);
1765
1766   /* Remove any notes we don't need.  That will make iterating
1767      over the instruction sequence faster, and allow the garbage
1768      collector to reclaim the memory used by the notes.  */
1769   remove_unnecessary_notes ();
1770
1771   /* Initialize some variables used by the optimizers.  */
1772   init_function_for_compilation ();
1773
1774   TREE_ASM_WRITTEN (current_function_decl) = 1;
1775
1776   /* Now that integrate will no longer see our rtl, we need not
1777      distinguish between the return value of this function and the
1778      return value of called functions.  Also, we can remove all SETs
1779      of subregs of hard registers; they are only here because of
1780      integrate.  Also, we can now initialize pseudos intended to
1781      carry magic hard reg data throughout the function.
1782
1783      FIXME: All this looks thoroughly obsolete... maybe we can
1784      get rid of both these lines unconditionally?  */
1785   rtx_equal_function_value_matters = 0;
1786   purge_hard_subreg_sets (get_insns ());
1787
1788   /* Early return if there were errors.  We can run afoul of our
1789      consistency checks, and there's not really much point in fixing them.  */
1790   if (rtl_dump_and_exit || flag_syntax_only || errorcount || sorrycount)
1791     goto exit_rest_of_compilation;
1792
1793   rest_of_handle_jump ();
1794   rest_of_handle_guess_branch_prob ();
1795
1796   if (cfun->tail_call_emit)
1797     fixup_tail_calls ();
1798
1799   rest_of_handle_eh ();
1800
1801   /* Delay emitting hard_reg_initial_value sets until after EH landing pad
1802      generation, which might create new sets.  */
1803   emit_initial_value_sets ();
1804
1805 #ifdef FINALIZE_PIC
1806   /* If we are doing position-independent code generation, now
1807      is the time to output special prologues and epilogues.
1808      We do not want to do this earlier, because it just clutters
1809      up inline functions with meaningless insns.  */
1810   if (flag_pic)
1811     FINALIZE_PIC;
1812 #endif
1813
1814   /* Copy any shared structure that should not be shared.  */
1815   unshare_all_rtl ();
1816
1817 #ifdef SETJMP_VIA_SAVE_AREA
1818   /* This must be performed before virtual register instantiation.
1819      Please be aware that everything in the compiler that can look
1820      at the RTL up to this point must understand that REG_SAVE_AREA
1821      is just like a use of the REG contained inside.  */
1822   if (current_function_calls_alloca)
1823     optimize_save_area_alloca ();
1824 #endif
1825
1826   /* Instantiate all virtual registers.  */
1827   instantiate_virtual_regs ();
1828
1829   rest_of_handle_jump2 ();
1830
1831   if (optimize > 0)
1832     rest_of_handle_cse ();
1833
1834   if (optimize > 0)
1835     {
1836       if (flag_gcse)
1837         rest_of_handle_gcse ();
1838
1839       if (flag_loop_optimize)
1840         rest_of_handle_loop_optimize ();
1841
1842       if (flag_gcse)
1843         rest_of_handle_jump_bypass ();
1844     }
1845
1846   timevar_push (TV_FLOW);
1847   rest_of_handle_cfg ();
1848
1849   if (!flag_tree_based_profiling
1850       && (optimize > 0 || profile_arc_flag
1851           || flag_test_coverage || flag_branch_probabilities))
1852     {
1853       rtl_register_profile_hooks ();
1854       rtl_register_value_prof_hooks ();
1855       rest_of_handle_branch_prob ();
1856
1857       if (flag_branch_probabilities
1858           && flag_profile_values
1859           && flag_value_profile_transformations)
1860         rest_of_handle_value_profile_transformations ();
1861
1862       /* Remove the death notes created for vpt.  */
1863       if (flag_profile_values)
1864         count_or_remove_death_notes (NULL, 1);
1865     }
1866
1867   if (optimize > 0)
1868     rest_of_handle_if_conversion ();
1869
1870   if (optimize > 0 && flag_tracer)
1871     rest_of_handle_tracer ();
1872
1873   if (optimize > 0
1874       && flag_loop_optimize2)
1875     rest_of_handle_loop2 ();
1876
1877   if (optimize > 0 && flag_web)
1878     rest_of_handle_web ();
1879
1880   if (optimize > 0 && flag_rerun_cse_after_loop)
1881     rest_of_handle_cse2 ();
1882
1883   cse_not_expected = 1;
1884
1885   rest_of_handle_life ();
1886   timevar_pop (TV_FLOW);
1887
1888   if (optimize > 0)
1889     rest_of_handle_combine ();
1890
1891   if (optimize > 0 && flag_if_conversion)
1892     rest_of_handle_if_after_combine ();
1893
1894   /* The optimization to partition hot/cold basic blocks into separate
1895      sections of the .o file does not work well with exception handling.
1896      Don't call it if there are exceptions.  */
1897
1898   if (optimize > 0 && flag_reorder_blocks_and_partition && !flag_exceptions)
1899     rest_of_handle_partition_blocks ();
1900
1901   if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
1902     rest_of_handle_regmove ();
1903
1904   /* Do unconditional splitting before register allocation to allow machine
1905      description to add extra information not needed previously.  */
1906   split_all_insns (1);
1907
1908 #ifdef OPTIMIZE_MODE_SWITCHING
1909   rest_of_handle_mode_switching ();
1910 #endif
1911
1912   /* Any of the several passes since flow1 will have munged register
1913      lifetime data a bit.  We need it to be up to date for scheduling
1914      (see handling of reg_known_equiv in init_alias_analysis).  */
1915   recompute_reg_usage (get_insns (), !optimize_size);
1916
1917 #ifdef INSN_SCHEDULING
1918   if (optimize > 0 && flag_modulo_sched)
1919     rest_of_handle_sms ();
1920
1921   if (flag_schedule_insns)
1922     rest_of_handle_sched ();
1923 #endif
1924
1925   /* Determine if the current function is a leaf before running reload
1926      since this can impact optimizations done by the prologue and
1927      epilogue thus changing register elimination offsets.  */
1928   current_function_is_leaf = leaf_function_p ();
1929
1930   if (flag_new_regalloc)
1931     {
1932       if (rest_of_handle_new_regalloc ())
1933         goto exit_rest_of_compilation;
1934     }
1935   else
1936     {
1937       if (rest_of_handle_old_regalloc ())
1938         goto exit_rest_of_compilation;
1939     }
1940
1941   if (optimize > 0)
1942     rest_of_handle_postreload ();
1943
1944   if (optimize > 0 && flag_gcse_after_reload)
1945     rest_of_handle_gcse2 ();
1946
1947   rest_of_handle_flow2 ();
1948
1949 #ifdef HAVE_peephole2
1950   if (optimize > 0 && flag_peephole2)
1951     rest_of_handle_peephole2 ();
1952 #endif
1953
1954   if (optimize > 0)
1955     rest_of_handle_if_after_reload ();
1956
1957   if (optimize > 0)
1958     {
1959       if (flag_rename_registers || flag_cprop_registers)
1960         rest_of_handle_regrename ();
1961
1962       rest_of_handle_reorder_blocks ();
1963     }
1964
1965   if (flag_branch_target_load_optimize2)
1966     rest_of_handle_branch_target_load_optimize ();
1967
1968 #ifdef LEAF_REGISTERS
1969   current_function_uses_only_leaf_regs
1970     = optimize > 0 && only_leaf_regs_used () && leaf_function_p ();
1971 #endif
1972
1973   if (targetm.late_rtl_prologue_epilogue)
1974     rest_of_handle_prologue_epilogue ();
1975
1976 #ifdef INSN_SCHEDULING
1977   if (optimize > 0 && flag_schedule_insns_after_reload)
1978     rest_of_handle_sched2 ();
1979 #endif
1980
1981 #ifdef STACK_REGS
1982   rest_of_handle_stack_regs ();
1983 #endif
1984
1985   compute_alignments ();
1986
1987   if (flag_var_tracking)
1988     rest_of_handle_variable_tracking ();
1989
1990   /* CFG is no longer maintained up-to-date.  */
1991   free_bb_for_insn ();
1992
1993   if (targetm.machine_dependent_reorg != 0)
1994     rest_of_handle_machine_reorg ();
1995
1996   purge_line_number_notes (get_insns ());
1997   cleanup_barriers ();
1998
1999 #ifdef DELAY_SLOTS
2000   if (flag_delayed_branch)
2001     rest_of_handle_delay_slots ();
2002 #endif
2003
2004 #if defined (HAVE_ATTR_length) && !defined (STACK_REGS)
2005   timevar_push (TV_SHORTEN_BRANCH);
2006   split_all_insns_noflow ();
2007   timevar_pop (TV_SHORTEN_BRANCH);
2008 #endif
2009
2010   convert_to_eh_region_ranges ();
2011
2012   rest_of_handle_shorten_branches ();
2013
2014   set_nothrow_function_flags ();
2015
2016   rest_of_handle_final ();
2017
2018  exit_rest_of_compilation:
2019
2020   rest_of_clean_state ();
2021 }
2022
2023 void
2024 init_optimization_passes (void)
2025 {
2026   open_dump_file (DFI_cgraph, NULL);
2027   cgraph_dump_file = dump_file;
2028   dump_file = NULL;
2029 }
2030
2031 void
2032 finish_optimization_passes (void)
2033 {
2034   timevar_push (TV_DUMP);
2035   if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
2036     {
2037       open_dump_file (DFI_bp, NULL);
2038       end_branch_prob ();
2039       close_dump_file (DFI_bp, NULL, NULL_RTX);
2040     }
2041
2042   if (optimize > 0 && open_dump_file (DFI_combine, NULL))
2043     {
2044       dump_combine_total_stats (dump_file);
2045       close_dump_file (DFI_combine, NULL, NULL_RTX);
2046     }
2047
2048   dump_file = cgraph_dump_file;
2049   cgraph_dump_file = NULL;
2050   close_dump_file (DFI_cgraph, NULL, NULL_RTX);
2051
2052   /* Do whatever is necessary to finish printing the graphs.  */
2053   if (graph_dump_format != no_graph)
2054     {
2055       int i;
2056
2057       for (i = 0; i < (int) DFI_MAX; ++i)
2058         if (dump_file_tbl[i].initialized && dump_file_tbl[i].graph_dump_p)
2059           {
2060             char seq[16];
2061             char *suffix;
2062
2063             sprintf (seq, DUMPFILE_FORMAT, i);
2064             suffix = concat (seq, dump_file_tbl[i].extension, NULL);
2065             finish_graph_dump_file (dump_base_name, suffix);
2066             free (suffix);
2067           }
2068     }
2069
2070   timevar_pop (TV_DUMP);
2071 }
2072
2073 bool
2074 enable_rtl_dump_file (int letter)
2075 {
2076   bool matched = false;
2077   int i;
2078
2079   if (letter == 'a')
2080     {
2081       for (i = 0; i < (int) DFI_MAX; ++i)
2082         dump_file_tbl[i].enabled = 1;
2083       matched = true;
2084     }
2085   else
2086     {
2087       for (i = 0; i < (int) DFI_MAX; ++i)
2088         if (letter == dump_file_tbl[i].debug_switch)
2089           {
2090             dump_file_tbl[i].enabled = 1;
2091             matched = true;
2092           }
2093     }
2094
2095   return matched;
2096 }
2097
2098 struct tree_opt_pass pass_rest_of_compilation =
2099 {
2100   "rest of compilation",                /* name */
2101   NULL,                                 /* gate */
2102   rest_of_compilation,                  /* execute */
2103   NULL,                                 /* sub */
2104   NULL,                                 /* next */
2105   0,                                    /* static_pass_number */
2106   TV_REST_OF_COMPILATION,               /* tv_id */
2107   PROP_rtl,                             /* properties_required */
2108   0,                                    /* properties_provided */
2109   PROP_rtl,                             /* properties_destroyed */
2110   0,                                    /* todo_flags_start */
2111   TODO_ggc_collect                      /* todo_flags_finish */
2112 };
2113
2114