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