cgraph.c (cgraph_node_name): New function.
[gcc.git] / gcc / toplev.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 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 "input.h"
44 #include "tree.h"
45 #include "rtl.h"
46 #include "tm_p.h"
47 #include "flags.h"
48 #include "insn-attr.h"
49 #include "insn-config.h"
50 #include "insn-flags.h"
51 #include "hard-reg-set.h"
52 #include "recog.h"
53 #include "output.h"
54 #include "except.h"
55 #include "function.h"
56 #include "toplev.h"
57 #include "expr.h"
58 #include "basic-block.h"
59 #include "intl.h"
60 #include "ggc.h"
61 #include "graph.h"
62 #include "loop.h"
63 #include "regs.h"
64 #include "timevar.h"
65 #include "diagnostic.h"
66 #include "ssa.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
82 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
83 #include "dwarf2out.h"
84 #endif
85
86 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
87 #include "dbxout.h"
88 #endif
89
90 #ifdef SDB_DEBUGGING_INFO
91 #include "sdbout.h"
92 #endif
93
94 #ifdef XCOFF_DEBUGGING_INFO
95 #include "xcoffout.h" /* Needed for external data
96 declarations for e.g. AIX 4.x. */
97 #endif
98
99 /* Carry information from ASM_DECLARE_OBJECT_NAME
100 to ASM_FINISH_DECLARE_OBJECT. */
101
102 extern int size_directive_output;
103 extern tree last_assemble_variable_decl;
104
105 extern void reg_alloc (void);
106
107 static void general_init (const char *);
108 static void do_compile (void);
109 static void process_options (void);
110 static void backend_init (void);
111 static int lang_dependent_init (const char *);
112 static void init_asm_output (const char *);
113 static void finalize (void);
114
115 static void crash_signal (int) ATTRIBUTE_NORETURN;
116 static void setup_core_dumping (void);
117 static void compile_file (void);
118
119 static int print_single_switch (FILE *, int, int, const char *,
120 const char *, const char *,
121 const char *, const char *);
122 static void print_switch_values (FILE *, int, int, const char *,
123 const char *, const char *);
124
125 /* Rest of compilation helper functions. */
126 static bool rest_of_handle_inlining (tree);
127 static rtx rest_of_handle_ssa (tree, rtx);
128 static void rest_of_handle_cse (tree, rtx);
129 static void rest_of_handle_cse2 (tree, rtx);
130 static void rest_of_handle_gcse (tree, rtx);
131 static void rest_of_handle_life (tree, rtx);
132 static void rest_of_handle_loop_optimize (tree, rtx);
133 static void rest_of_handle_loop2 (tree, rtx);
134 static void rest_of_handle_jump_bypass (tree, rtx);
135 static void rest_of_handle_sibling_calls (rtx);
136 static void rest_of_handle_null_pointer (tree, rtx);
137 static void rest_of_handle_addresof (tree, rtx);
138 static void rest_of_handle_cfg (tree, rtx);
139 static void rest_of_handle_branch_prob (tree, rtx);
140 static void rest_of_handle_if_conversion (tree, rtx);
141 static void rest_of_handle_if_after_combine (tree, rtx);
142 static void rest_of_handle_tracer (tree, rtx);
143 static void rest_of_handle_combine (tree, rtx);
144 static void rest_of_handle_regmove (tree, rtx);
145 #ifdef INSN_SCHEDULING
146 static void rest_of_handle_sched (tree, rtx);
147 static void rest_of_handle_sched2 (tree, rtx);
148 #endif
149 static bool rest_of_handle_new_regalloc (tree, rtx, int *);
150 static bool rest_of_handle_old_regalloc (tree, rtx, int *);
151 static void rest_of_handle_regrename (tree, rtx);
152 static void rest_of_handle_reorder_blocks (tree, rtx);
153 #ifdef STACK_REGS
154 static void rest_of_handle_stack_regs (tree, rtx);
155 #endif
156 static void rest_of_handle_machine_reorg (tree, rtx);
157 #ifdef DELAY_SLOTS
158 static void rest_of_handle_delay_slots (tree, rtx);
159 #endif
160 static void rest_of_handle_final (tree, rtx);
161
162 /* Nonzero to dump debug info whilst parsing (-dy option). */
163 static int set_yydebug;
164
165 /* True if we don't need a backend (e.g. preprocessing only). */
166 static bool no_backend;
167
168 /* Length of line when printing switch values. */
169 #define MAX_LINE 75
170
171 /* Name of program invoked, sans directories. */
172
173 const char *progname;
174
175 /* Copy of argument vector to toplev_main. */
176 static const char **save_argv;
177
178 /* Name of top-level original source file (what was input to cpp).
179 This comes from the #-command at the beginning of the actual input.
180 If there isn't any there, then this is the cc1 input file name. */
181
182 const char *main_input_filename;
183
184 /* Current position in real source file. */
185
186 location_t input_location;
187
188 /* Nonzero if it is unsafe to create any new pseudo registers. */
189 int no_new_pseudos;
190
191 /* Stack of currently pending input files. */
192
193 struct file_stack *input_file_stack;
194
195 /* Incremented on each change to input_file_stack. */
196 int input_file_stack_tick;
197
198 /* Name to use as base of names for dump output files. */
199
200 const char *dump_base_name;
201
202 /* Name to use as a base for auxiliary output files. */
203
204 const char *aux_base_name;
205
206 /* Format to use to print dumpfile index value */
207 #ifndef DUMPFILE_FORMAT
208 #define DUMPFILE_FORMAT ".%02d."
209 #endif
210
211 /* Bit flags that specify the machine subtype we are compiling for.
212 Bits are tested using macros TARGET_... defined in the tm.h file
213 and set by `-m...' switches. Must be defined in rtlanal.c. */
214
215 extern int target_flags;
216
217 /* A mask of target_flags that includes bit X if X was set or cleared
218 on the command line. */
219
220 int target_flags_explicit;
221
222 /* Debug hooks - dependent upon command line options. */
223
224 const struct gcc_debug_hooks *debug_hooks = &do_nothing_debug_hooks;
225
226 /* Describes a dump file. */
227
228 struct dump_file_info
229 {
230 /* The unique extension to apply, e.g. ".jump". */
231 const char *const extension;
232
233 /* The -d<c> character that enables this dump file. */
234 char const debug_switch;
235
236 /* True if there is a corresponding graph dump file. */
237 char const graph_dump_p;
238
239 /* True if the user selected this dump. */
240 char enabled;
241
242 /* True if the files have been initialized (ie truncated). */
243 char initialized;
244 };
245
246 /* Enumerate the extant dump files. */
247
248 enum dump_file_index
249 {
250 DFI_cgraph,
251 DFI_rtl,
252 DFI_sibling,
253 DFI_eh,
254 DFI_jump,
255 DFI_ssa,
256 DFI_ssa_ccp,
257 DFI_ssa_dce,
258 DFI_ussa,
259 DFI_null,
260 DFI_cse,
261 DFI_addressof,
262 DFI_gcse,
263 DFI_loop,
264 DFI_bypass,
265 DFI_cfg,
266 DFI_bp,
267 DFI_ce1,
268 DFI_tracer,
269 DFI_loop2,
270 DFI_cse2,
271 DFI_life,
272 DFI_combine,
273 DFI_ce2,
274 DFI_regmove,
275 DFI_sched,
276 DFI_lreg,
277 DFI_greg,
278 DFI_postreload,
279 DFI_flow2,
280 DFI_peephole2,
281 DFI_rnreg,
282 DFI_bbro,
283 DFI_ce3,
284 DFI_branch_target_load,
285 DFI_sched2,
286 DFI_stack,
287 DFI_mach,
288 DFI_dbr,
289 DFI_MAX
290 };
291
292 /* Describes all the dump files. Should be kept in order of the
293 pass and in sync with dump_file_index above.
294
295 Remaining -d letters:
296
297 " m q "
298 " JK O Q V YZ"
299 */
300
301 static struct dump_file_info dump_file[DFI_MAX] =
302 {
303 { "cgraph", 'U', 0, 0, 0 },
304 { "rtl", 'r', 0, 0, 0 },
305 { "sibling", 'i', 0, 0, 0 },
306 { "eh", 'h', 0, 0, 0 },
307 { "jump", 'j', 0, 0, 0 },
308 { "ssa", 'e', 1, 0, 0 },
309 { "ssaccp", 'W', 1, 0, 0 },
310 { "ssadce", 'X', 1, 0, 0 },
311 { "ussa", 'e', 1, 0, 0 }, /* Yes, duplicate enable switch. */
312 { "null", 'u', 0, 0, 0 },
313 { "cse", 's', 0, 0, 0 },
314 { "addressof", 'F', 0, 0, 0 },
315 { "gcse", 'G', 1, 0, 0 },
316 { "loop", 'L', 1, 0, 0 },
317 { "bypass", 'G', 1, 0, 0 }, /* Yes, duplicate enable switch. */
318 { "cfg", 'f', 1, 0, 0 },
319 { "bp", 'b', 1, 0, 0 },
320 { "ce1", 'C', 1, 0, 0 },
321 { "tracer", 'T', 1, 0, 0 },
322 { "loop2", 'L', 1, 0, 0 },
323 { "cse2", 't', 1, 0, 0 },
324 { "life", 'f', 1, 0, 0 }, /* Yes, duplicate enable switch. */
325 { "combine", 'c', 1, 0, 0 },
326 { "ce2", 'C', 1, 0, 0 },
327 { "regmove", 'N', 1, 0, 0 },
328 { "sched", 'S', 1, 0, 0 },
329 { "lreg", 'l', 1, 0, 0 },
330 { "greg", 'g', 1, 0, 0 },
331 { "postreload", 'o', 1, 0, 0 },
332 { "flow2", 'w', 1, 0, 0 },
333 { "peephole2", 'z', 1, 0, 0 },
334 { "rnreg", 'n', 1, 0, 0 },
335 { "bbro", 'B', 1, 0, 0 },
336 { "ce3", 'E', 1, 0, 0 },
337 { "btl", 'd', 1, 0, 0 }, /* Yes, duplicate enable switch. */
338 { "sched2", 'R', 1, 0, 0 },
339 { "stack", 'k', 1, 0, 0 },
340 { "mach", 'M', 1, 0, 0 },
341 { "dbr", 'd', 0, 0, 0 },
342 };
343
344 static int open_dump_file (enum dump_file_index, tree);
345 static void close_dump_file (enum dump_file_index,
346 void (*) (FILE *, rtx), rtx);
347
348 /* Other flags saying which kinds of debugging dump have been requested. */
349
350 int rtl_dump_and_exit;
351 int flag_print_asm_name;
352 enum graph_dump_types graph_dump_format;
353
354 /* Name for output file of assembly code, specified with -o. */
355
356 const char *asm_file_name;
357
358 /* Type(s) of debugging information we are producing (if any).
359 See flags.h for the definitions of the different possible
360 types of debugging information. */
361 enum debug_info_type write_symbols = NO_DEBUG;
362
363 /* Level of debugging information we are producing. See flags.h
364 for the definitions of the different possible levels. */
365 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
366
367 /* Nonzero means use GNU-only extensions in the generated symbolic
368 debugging information. */
369 /* Currently, this only has an effect when write_symbols is set to
370 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
371 int use_gnu_debug_info_extensions = 0;
372
373 /* Nonzero means do optimizations. -O.
374 Particular numeric values stand for particular amounts of optimization;
375 thus, -O2 stores 2 here. However, the optimizations beyond the basic
376 ones are not controlled directly by this variable. Instead, they are
377 controlled by individual `flag_...' variables that are defaulted
378 based on this variable. */
379
380 int optimize = 0;
381
382 /* Nonzero means optimize for size. -Os.
383 The only valid values are zero and nonzero. When optimize_size is
384 nonzero, optimize defaults to 2, but certain individual code
385 bloating optimizations are disabled. */
386
387 int optimize_size = 0;
388
389 /* The FUNCTION_DECL for the function currently being compiled,
390 or 0 if between functions. */
391 tree current_function_decl;
392
393 /* Set to the FUNC_BEGIN label of the current function, or NULL_TREE
394 if none. */
395 tree current_function_func_begin_label;
396
397 /* Nonzero if doing dwarf2 duplicate elimination. */
398
399 int flag_eliminate_dwarf2_dups = 0;
400
401 /* Nonzero if doing unused type elimination. */
402
403 int flag_eliminate_unused_debug_types = 1;
404
405 /* Nonzero means emit debugging information only for symbols which are used. */
406 int flag_debug_only_used_symbols = 0;
407
408 /* Nonzero if generating code to do profiling. */
409
410 int profile_flag = 0;
411
412 /* Nonzero if generating code to profile program flow graph arcs. */
413
414 int profile_arc_flag = 0;
415
416 /* Nonzero if value histograms should be measured. */
417
418 int flag_profile_values = 0;
419
420 /* Nonzero if generating info for gcov to calculate line test coverage. */
421
422 int flag_test_coverage = 0;
423
424 /* Nonzero indicates that branch taken probabilities should be calculated. */
425
426 int flag_branch_probabilities = 0;
427
428 /* Nonzero if basic blocks should be reordered. */
429
430 int flag_reorder_blocks = 0;
431
432 /* Nonzero if functions should be reordered. */
433
434 int flag_reorder_functions = 0;
435
436 /* Nonzero if registers should be renamed. */
437
438 int flag_rename_registers = 0;
439 int flag_cprop_registers = 0;
440
441 /* Nonzero for -pedantic switch: warn about anything
442 that standard spec forbids. */
443
444 int pedantic = 0;
445
446 /* Temporarily suppress certain warnings.
447 This is set while reading code from a system header file. */
448
449 int in_system_header = 0;
450
451 /* Don't print functions as they are compiled. -quiet. */
452
453 int quiet_flag = 0;
454
455 /* Print times taken by the various passes. -ftime-report. */
456
457 int time_report = 0;
458
459 /* Print memory still in use at end of compilation (which may have little
460 to do with peak memory consumption). -fmem-report. */
461
462 int mem_report = 0;
463
464 /* Nonzero means to collect statistics which might be expensive
465 and to print them when we are done. */
466 int flag_detailed_statistics = 0;
467
468 /* A random sequence of characters, unless overridden by user. */
469 const char *flag_random_seed;
470
471 /* A local time stamp derived from the time of compilation. It will be
472 zero if the system cannot provide a time. It will be -1u, if the
473 user has specified a particular random seed. */
474 unsigned local_tick;
475
476 /* -f flags. */
477
478 /* Nonzero means `char' should be signed. */
479
480 int flag_signed_char;
481
482 /* Nonzero means give an enum type only as many bytes as it needs. */
483
484 int flag_short_enums;
485
486 /* Nonzero for -fcaller-saves: allocate values in regs that need to
487 be saved across function calls, if that produces overall better code.
488 Optional now, so people can test it. */
489
490 #ifdef DEFAULT_CALLER_SAVES
491 int flag_caller_saves = 1;
492 #else
493 int flag_caller_saves = 0;
494 #endif
495
496 /* Nonzero if structures and unions should be returned in memory.
497
498 This should only be defined if compatibility with another compiler or
499 with an ABI is needed, because it results in slower code. */
500
501 #ifndef DEFAULT_PCC_STRUCT_RETURN
502 #define DEFAULT_PCC_STRUCT_RETURN 1
503 #endif
504
505 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
506
507 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
508
509 /* Nonzero for -fforce-mem: load memory value into a register
510 before arithmetic on it. This makes better cse but slower compilation. */
511
512 int flag_force_mem = 0;
513
514 /* Nonzero for -fforce-addr: load memory address into a register before
515 reference to memory. This makes better cse but slower compilation. */
516
517 int flag_force_addr = 0;
518
519 /* Nonzero for -fdefer-pop: don't pop args after each function call;
520 instead save them up to pop many calls' args with one insns. */
521
522 int flag_defer_pop = 0;
523
524 /* Nonzero for -ffloat-store: don't allocate floats and doubles
525 in extended-precision registers. */
526
527 int flag_float_store = 0;
528
529 /* Nonzero for -fcse-follow-jumps:
530 have cse follow jumps to do a more extensive job. */
531
532 int flag_cse_follow_jumps;
533
534 /* Nonzero for -fcse-skip-blocks:
535 have cse follow a branch around a block. */
536 int flag_cse_skip_blocks;
537
538 /* Nonzero for -fexpensive-optimizations:
539 perform miscellaneous relatively-expensive optimizations. */
540 int flag_expensive_optimizations;
541
542 /* Nonzero for -fthread-jumps:
543 have jump optimize output of loop. */
544
545 int flag_thread_jumps;
546
547 /* Nonzero enables strength-reduction in loop.c. */
548
549 int flag_strength_reduce = 0;
550
551 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
552 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
553 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
554 unrolled. */
555
556 int flag_old_unroll_loops;
557
558 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
559 This is generally not a win. */
560
561 int flag_old_unroll_all_loops;
562
563 /* Enables unrolling of simple loops in loop-unroll.c. */
564 int flag_unroll_loops;
565
566 /* Enables unrolling of all loops in loop-unroll.c. */
567 int flag_unroll_all_loops;
568
569 /* Nonzero enables loop peeling. */
570 int flag_peel_loops;
571
572 /* Nonzero enables loop unswitching. */
573 int flag_unswitch_loops;
574
575 /* Nonzero enables prefetch optimizations for arrays in loops. */
576
577 int flag_prefetch_loop_arrays;
578
579 /* Nonzero forces all invariant computations in loops to be moved
580 outside the loop. */
581
582 int flag_move_all_movables = 0;
583
584 /* Nonzero forces all general induction variables in loops to be
585 strength reduced. */
586
587 int flag_reduce_all_givs = 0;
588
589 /* Nonzero to perform full register move optimization passes. This is the
590 default for -O2. */
591
592 int flag_regmove = 0;
593
594 /* Nonzero for -fwritable-strings:
595 store string constants in data segment and don't uniquize them. */
596
597 int flag_writable_strings = 0;
598
599 /* Nonzero means don't put addresses of constant functions in registers.
600 Used for compiling the Unix kernel, where strange substitutions are
601 done on the assembly output. */
602
603 int flag_no_function_cse = 0;
604
605 /* Nonzero for -fomit-frame-pointer:
606 don't make a frame pointer in simple functions that don't require one. */
607
608 int flag_omit_frame_pointer = 0;
609
610 /* Nonzero means place each function into its own section on those platforms
611 which support arbitrary section names and unlimited numbers of sections. */
612
613 int flag_function_sections = 0;
614
615 /* ... and similar for data. */
616
617 int flag_data_sections = 0;
618
619 /* Nonzero to inhibit use of define_optimization peephole opts. */
620
621 int flag_no_peephole = 0;
622
623 /* Nonzero allows GCC to optimize sibling and tail recursive calls. */
624
625 int flag_optimize_sibling_calls = 0;
626
627 /* Nonzero means the front end generally wants `errno' maintained by math
628 operations, like built-in SQRT. */
629
630 int flag_errno_math = 1;
631
632 /* Nonzero means that unsafe floating-point math optimizations are allowed
633 for the sake of speed. IEEE compliance is not guaranteed, and operations
634 are allowed to assume that their arguments and results are "normal"
635 (e.g., nonnegative for SQRT). */
636
637 int flag_unsafe_math_optimizations = 0;
638
639 /* Nonzero means that no NaNs or +-Infs are expected. */
640
641 int flag_finite_math_only = 0;
642
643 /* Zero means that floating-point math operations cannot generate a
644 (user-visible) trap. This is the case, for example, in nonstop
645 IEEE 754 arithmetic. Trapping conditions include division by zero,
646 overflow, underflow, invalid and inexact, but does not include
647 operations on signaling NaNs (see below). */
648
649 int flag_trapping_math = 1;
650
651 /* Nonzero means disable transformations observable by signaling NaNs.
652 This option implies that any operation on an IEEE signaling NaN can
653 generate a (user-visible) trap. */
654
655 int flag_signaling_nans = 0;
656
657 /* 0 means straightforward implementation of complex divide acceptable.
658 1 means wide ranges of inputs must work for complex divide.
659 2 means C99-like requirements for complex divide (not yet implemented). */
660
661 int flag_complex_divide_method = 0;
662
663 /* Nonzero means just do syntax checking; don't output anything. */
664
665 int flag_syntax_only = 0;
666
667 /* Nonzero means perform loop optimizer. */
668
669 int flag_loop_optimize;
670
671 /* Nonzero means perform crossjumping. */
672
673 int flag_crossjumping;
674
675 /* Nonzero means perform if conversion. */
676
677 int flag_if_conversion;
678
679 /* Nonzero means perform if conversion after reload. */
680
681 int flag_if_conversion2;
682
683 /* Nonzero means to use global dataflow analysis to eliminate
684 useless null pointer tests. */
685
686 int flag_delete_null_pointer_checks;
687
688 /* Nonzero means perform global CSE. */
689
690 int flag_gcse = 0;
691
692 /* Nonzero means to do the enhanced load motion during gcse, which trys
693 to hoist loads by not killing them when a store to the same location
694 is seen. */
695
696 int flag_gcse_lm = 1;
697
698 /* Nonzero means to perform store motion after gcse, which will try to
699 move stores closer to the exit block. Its not very effective without
700 flag_gcse_lm. */
701
702 int flag_gcse_sm = 1;
703
704 /* Perform target register optimization before prologue / epilogue
705 threading. */
706
707 int flag_branch_target_load_optimize = 0;
708
709 /* Perform target register optimization after prologue / epilogue
710 threading and jump2. */
711
712 int flag_branch_target_load_optimize2 = 0;
713
714 /* Nonzero means to rerun cse after loop optimization. This increases
715 compilation time about 20% and picks up a few more common expressions. */
716
717 int flag_rerun_cse_after_loop;
718
719 /* Nonzero means to run loop optimizations twice. */
720
721 int flag_rerun_loop_opt;
722
723 /* Nonzero for -finline-functions: ok to inline functions that look like
724 good inline candidates. */
725
726 int flag_inline_functions;
727
728 /* Nonzero for -fkeep-inline-functions: even if we make a function
729 go inline everywhere, keep its definition around for debugging
730 purposes. */
731
732 int flag_keep_inline_functions;
733
734 /* Nonzero means that functions will not be inlined. */
735
736 int flag_no_inline = 2;
737
738 /* Nonzero means that we don't want inlining by virtue of -fno-inline,
739 not just because the tree inliner turned us off. */
740
741 int flag_really_no_inline = 2;
742
743 /* Nonzero means that we should emit static const variables
744 regardless of whether or not optimization is turned on. */
745
746 int flag_keep_static_consts = 1;
747
748 /* Nonzero means we should be saving declaration info into a .X file. */
749
750 int flag_gen_aux_info = 0;
751
752 /* Specified name of aux-info file. */
753
754 const char *aux_info_file_name;
755
756 /* Nonzero means make the text shared if supported. */
757
758 int flag_shared_data;
759
760 /* Nonzero means schedule into delayed branch slots if supported. */
761
762 int flag_delayed_branch;
763
764 /* Nonzero if we are compiling pure (sharable) code.
765 Value is 1 if we are doing "small" pic; value is 2 if we're doing
766 "large" pic. */
767
768 int flag_pic;
769
770 /* Nonzero if we are compiling position independent code for executable.
771 The value is 1 if we are doing "small" pic; value is 2 if we're doing
772 "large" pic. */
773
774 int flag_pie;
775
776 /* Nonzero if we are compiling code for a shared library, zero for
777 executable. */
778
779 int flag_shlib;
780
781 /* Set to the default thread-local storage (tls) model to use. */
782
783 enum tls_model flag_tls_default = TLS_MODEL_GLOBAL_DYNAMIC;
784
785 /* Nonzero means generate extra code for exception handling and enable
786 exception handling. */
787
788 int flag_exceptions;
789
790 /* Nonzero means generate frame unwind info table when supported. */
791
792 int flag_unwind_tables = 0;
793
794 /* Nonzero means generate frame unwind info table exact at each insn
795 boundary. */
796
797 int flag_asynchronous_unwind_tables = 0;
798
799 /* Nonzero means don't place uninitialized global data in common storage
800 by default. */
801
802 int flag_no_common;
803
804 /* Nonzero means change certain warnings into errors.
805 Usually these are warnings about failure to conform to some standard. */
806
807 int flag_pedantic_errors = 0;
808
809 /* flag_schedule_insns means schedule insns within basic blocks (before
810 local_alloc).
811 flag_schedule_insns_after_reload means schedule insns after
812 global_alloc. */
813
814 int flag_schedule_insns = 0;
815 int flag_schedule_insns_after_reload = 0;
816
817 /* When flag_schedule_insns_after_reload is set, use EBB scheduler. */
818 int flag_sched2_use_superblocks = 0;
819
820 /* When flag_schedule_insns_after_reload is set, construct traces and EBB
821 scheduler. */
822 int flag_sched2_use_traces = 0;
823
824 /* The following flags have effect only for scheduling before register
825 allocation:
826
827 flag_schedule_interblock means schedule insns across basic blocks.
828 flag_schedule_speculative means allow speculative motion of non-load insns.
829 flag_schedule_speculative_load means allow speculative motion of some
830 load insns.
831 flag_schedule_speculative_load_dangerous allows speculative motion of more
832 load insns. */
833
834 int flag_schedule_interblock = 1;
835 int flag_schedule_speculative = 1;
836 int flag_schedule_speculative_load = 0;
837 int flag_schedule_speculative_load_dangerous = 0;
838
839 int flag_single_precision_constant;
840
841 /* flag_branch_on_count_reg means try to replace add-1,compare,branch tupple
842 by a cheaper branch on a count register. */
843 int flag_branch_on_count_reg = 1;
844
845 /* -finhibit-size-directive inhibits output of .size for ELF.
846 This is used only for compiling crtstuff.c,
847 and it may be extended to other effects
848 needed for crtstuff.c on other systems. */
849 int flag_inhibit_size_directive = 0;
850
851 /* -fverbose-asm causes extra commentary information to be produced in
852 the generated assembly code (to make it more readable). This option
853 is generally only of use to those who actually need to read the
854 generated assembly code (perhaps while debugging the compiler itself).
855 -fno-verbose-asm, the default, causes the extra information
856 to be omitted and is useful when comparing two assembler files. */
857
858 int flag_verbose_asm = 0;
859
860 /* -dA causes debug commentary information to be produced in
861 the generated assembly code (to make it more readable). This option
862 is generally only of use to those who actually need to read the
863 generated assembly code (perhaps while debugging the compiler itself).
864 Currently, this switch is only used by dwarfout.c; however, it is intended
865 to be a catchall for printing debug information in the assembler file. */
866
867 int flag_debug_asm = 0;
868
869 /* -dP causes the rtl to be emitted as a comment in assembly. */
870
871 int flag_dump_rtl_in_asm = 0;
872
873 /* -fgnu-linker specifies use of the GNU linker for initializations.
874 (Or, more generally, a linker that handles initializations.)
875 -fno-gnu-linker says that collect2 will be used. */
876 #ifdef USE_COLLECT2
877 int flag_gnu_linker = 0;
878 #else
879 int flag_gnu_linker = 1;
880 #endif
881
882 /* Nonzero means put zero initialized data in the bss section. */
883 int flag_zero_initialized_in_bss = 1;
884
885 /* Enable SSA. */
886 int flag_ssa = 0;
887
888 /* Enable ssa conditional constant propagation. */
889 int flag_ssa_ccp = 0;
890
891 /* Enable ssa aggressive dead code elimination. */
892 int flag_ssa_dce = 0;
893
894 /* Tag all structures with __attribute__(packed). */
895 int flag_pack_struct = 0;
896
897 /* Emit code to check for stack overflow; also may cause large objects
898 to be allocated dynamically. */
899 int flag_stack_check;
900
901 /* When non-NULL, indicates that whenever space is allocated on the
902 stack, the resulting stack pointer must not pass this
903 address---that is, for stacks that grow downward, the stack pointer
904 must always be greater than or equal to this address; for stacks
905 that grow upward, the stack pointer must be less than this address.
906 At present, the rtx may be either a REG or a SYMBOL_REF, although
907 the support provided depends on the backend. */
908 rtx stack_limit_rtx;
909
910 /* 0 if pointer arguments may alias each other. True in C.
911 1 if pointer arguments may not alias each other but may alias
912 global variables.
913 2 if pointer arguments may not alias each other and may not
914 alias global variables. True in Fortran.
915 This defaults to 0 for C. */
916 int flag_argument_noalias = 0;
917
918 /* Nonzero if we should do (language-dependent) alias analysis.
919 Typically, this analysis will assume that expressions of certain
920 types do not alias expressions of certain other types. Only used
921 if alias analysis (in general) is enabled. */
922 int flag_strict_aliasing = 0;
923
924 /* Instrument functions with calls at entry and exit, for profiling. */
925 int flag_instrument_function_entry_exit = 0;
926
927 /* Nonzero means ignore `#ident' directives. 0 means handle them.
928 On SVR4 targets, it also controls whether or not to emit a
929 string identifying the compiler. */
930
931 int flag_no_ident = 0;
932
933 /* This will perform a peephole pass before sched2. */
934 int flag_peephole2 = 0;
935
936 /* This will try to guess branch probabilities. */
937 int flag_guess_branch_prob = 0;
938
939 /* -fcheck-bounds causes gcc to generate array bounds checks.
940 For C, C++, ObjC: defaults to off.
941 For Java: defaults to on.
942 For Fortran: defaults to off. */
943 int flag_bounds_check = 0;
944
945 /* This will attempt to merge constant section constants, if 1 only
946 string constants and constants from constant pool, if 2 also constant
947 variables. */
948 int flag_merge_constants = 1;
949
950 /* If one, renumber instruction UIDs to reduce the number of
951 unused UIDs if there are a lot of instructions. If greater than
952 one, unconditionally renumber instruction UIDs. */
953 int flag_renumber_insns = 1;
954
955 /* If nonzero, use the graph coloring register allocator. */
956 int flag_new_regalloc = 0;
957
958 /* Nonzero if we perform superblock formation. */
959
960 int flag_tracer = 0;
961
962 /* Nonzero if we perform whole unit at a time compilation. */
963
964 int flag_unit_at_a_time = 0;
965
966 /* Values of the -falign-* flags: how much to align labels in code.
967 0 means `use default', 1 means `don't align'.
968 For each variable, there is an _log variant which is the power
969 of two not less than the variable, for .align output. */
970
971 int align_loops;
972 int align_loops_log;
973 int align_loops_max_skip;
974 int align_jumps;
975 int align_jumps_log;
976 int align_jumps_max_skip;
977 int align_labels;
978 int align_labels_log;
979 int align_labels_max_skip;
980 int align_functions;
981 int align_functions_log;
982
983 /* Like align_functions_log above, but used by front-ends to force the
984 minimum function alignment. Zero means no alignment is forced. */
985 int force_align_functions_log;
986
987 /* Table of supported debugging formats. */
988 static const struct
989 {
990 const char *const arg;
991 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
992 constant expression, we use NO_DEBUG in its place. */
993 const enum debug_info_type debug_type;
994 const int use_extensions_p;
995 const char *const description;
996 } *da,
997 debug_args[] =
998 {
999 { "", NO_DEBUG, DEFAULT_GDB_EXTENSIONS,
1000 N_("Generate debugging info in default format") },
1001 { "gdb", NO_DEBUG, 1, N_("Generate debugging info in default extended format") },
1002 #ifdef DBX_DEBUGGING_INFO
1003 { "stabs", DBX_DEBUG, 0, N_("Generate STABS format debug info") },
1004 { "stabs+", DBX_DEBUG, 1, N_("Generate extended STABS format debug info") },
1005 #endif
1006 #ifdef DWARF_DEBUGGING_INFO
1007 { "dwarf", DWARF_DEBUG, 0, N_("Generate DWARF-1 format debug info") },
1008 { "dwarf+", DWARF_DEBUG, 1,
1009 N_("Generate extended DWARF-1 format debug info") },
1010 #endif
1011 #ifdef DWARF2_DEBUGGING_INFO
1012 { "dwarf-2", DWARF2_DEBUG, 0, N_("Generate DWARF-2 debug info") },
1013 #endif
1014 #ifdef XCOFF_DEBUGGING_INFO
1015 { "xcoff", XCOFF_DEBUG, 0, N_("Generate XCOFF format debug info") },
1016 { "xcoff+", XCOFF_DEBUG, 1, N_("Generate extended XCOFF format debug info") },
1017 #endif
1018 #ifdef SDB_DEBUGGING_INFO
1019 { "coff", SDB_DEBUG, 0, N_("Generate COFF format debug info") },
1020 #endif
1021 #ifdef VMS_DEBUGGING_INFO
1022 { "vms", VMS_DEBUG, 0, N_("Generate VMS format debug info") },
1023 #endif
1024 { 0, 0, 0, 0 }
1025 };
1026
1027 typedef struct
1028 {
1029 const char *const string;
1030 int *const variable;
1031 const int on_value;
1032 const char *const description;
1033 }
1034 lang_independent_options;
1035
1036 /* Nonzero if signed arithmetic overflow should trap. */
1037 int flag_trapv = 0;
1038
1039 /* Nonzero if signed arithmetic overflow should wrap around. */
1040 int flag_wrapv = 0;
1041
1042 /* Add or remove a leading underscore from user symbols. */
1043 int flag_leading_underscore = -1;
1044
1045 /* The user symbol prefix after having resolved same. */
1046 const char *user_label_prefix;
1047
1048 static const param_info lang_independent_params[] = {
1049 #define DEFPARAM(ENUM, OPTION, HELP, DEFAULT) \
1050 { OPTION, DEFAULT, HELP },
1051 #include "params.def"
1052 #undef DEFPARAM
1053 { NULL, 0, NULL }
1054 };
1055
1056 /* Table of language-independent -f options.
1057 STRING is the option name. VARIABLE is the address of the variable.
1058 ON_VALUE is the value to store in VARIABLE
1059 if `-fSTRING' is seen as an option.
1060 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
1061
1062 static const lang_independent_options f_options[] =
1063 {
1064 {"eliminate-dwarf2-dups", &flag_eliminate_dwarf2_dups, 1,
1065 N_("Perform DWARF2 duplicate elimination") },
1066 {"eliminate-unused-debug-symbols", &flag_debug_only_used_symbols, 1,
1067 N_("Perform unused type elimination in debug info") },
1068 {"eliminate-unused-debug-types", &flag_eliminate_unused_debug_types, 1,
1069 N_("Perform unused type elimination in debug info") },
1070 {"float-store", &flag_float_store, 1,
1071 N_("Do not store floats in registers") },
1072 {"defer-pop", &flag_defer_pop, 1,
1073 N_("Defer popping functions args from stack until later") },
1074 {"omit-frame-pointer", &flag_omit_frame_pointer, 1,
1075 N_("When possible do not generate stack frames") },
1076 {"optimize-sibling-calls", &flag_optimize_sibling_calls, 1,
1077 N_("Optimize sibling and tail recursive calls") },
1078 {"tracer", &flag_tracer, 1,
1079 N_("Perform superblock formation via tail duplication") },
1080 {"unit-at-a-time", &flag_unit_at_a_time, 1,
1081 N_("Compile whole compilation unit at a time") },
1082 {"cse-follow-jumps", &flag_cse_follow_jumps, 1,
1083 N_("When running CSE, follow jumps to their targets") },
1084 {"cse-skip-blocks", &flag_cse_skip_blocks, 1,
1085 N_("When running CSE, follow conditional jumps") },
1086 {"expensive-optimizations", &flag_expensive_optimizations, 1,
1087 N_("Perform a number of minor, expensive optimizations") },
1088 {"thread-jumps", &flag_thread_jumps, 1,
1089 N_("Perform jump threading optimizations") },
1090 {"strength-reduce", &flag_strength_reduce, 1,
1091 N_("Perform strength reduction optimizations") },
1092 {"unroll-loops", &flag_unroll_loops, 1,
1093 N_("Perform loop unrolling when iteration count is known") },
1094 {"unroll-all-loops", &flag_unroll_all_loops, 1,
1095 N_("Perform loop unrolling for all loops") },
1096 {"old-unroll-loops", &flag_old_unroll_loops, 1,
1097 N_("Perform loop unrolling when iteration count is known") },
1098 {"old-unroll-all-loops", &flag_old_unroll_all_loops, 1,
1099 N_("Perform loop unrolling for all loops") },
1100 {"peel-loops", &flag_peel_loops, 1,
1101 N_("Perform loop peeling") },
1102 {"unswitch-loops", &flag_unswitch_loops, 1,
1103 N_("Perform loop unswitching") },
1104 {"prefetch-loop-arrays", &flag_prefetch_loop_arrays, 1,
1105 N_("Generate prefetch instructions, if available, for arrays in loops") },
1106 {"move-all-movables", &flag_move_all_movables, 1,
1107 N_("Force all loop invariant computations out of loops") },
1108 {"reduce-all-givs", &flag_reduce_all_givs, 1,
1109 N_("Strength reduce all loop general induction variables") },
1110 {"writable-strings", &flag_writable_strings, 1,
1111 N_("Store strings in writable data section") },
1112 {"peephole", &flag_no_peephole, 0,
1113 N_("Enable machine specific peephole optimizations") },
1114 {"force-mem", &flag_force_mem, 1,
1115 N_("Copy memory operands into registers before using") },
1116 {"force-addr", &flag_force_addr, 1,
1117 N_("Copy memory address constants into regs before using") },
1118 {"function-cse", &flag_no_function_cse, 0,
1119 N_("Allow function addresses to be held in registers") },
1120 {"inline-functions", &flag_inline_functions, 1,
1121 N_("Integrate simple functions into their callers") },
1122 {"keep-inline-functions", &flag_keep_inline_functions, 1,
1123 N_("Generate code for funcs even if they are fully inlined") },
1124 {"inline", &flag_no_inline, 0,
1125 N_("Pay attention to the 'inline' keyword") },
1126 {"keep-static-consts", &flag_keep_static_consts, 1,
1127 N_("Emit static const variables even if they are not used") },
1128 {"syntax-only", &flag_syntax_only, 1,
1129 N_("Check for syntax errors, then stop") },
1130 {"shared-data", &flag_shared_data, 1,
1131 N_("Mark data as shared rather than private") },
1132 {"caller-saves", &flag_caller_saves, 1,
1133 N_("Enable saving registers around function calls") },
1134 {"pcc-struct-return", &flag_pcc_struct_return, 1,
1135 N_("Return 'short' aggregates in memory, not registers") },
1136 {"reg-struct-return", &flag_pcc_struct_return, 0,
1137 N_("Return 'short' aggregates in registers") },
1138 {"delayed-branch", &flag_delayed_branch, 1,
1139 N_("Attempt to fill delay slots of branch instructions") },
1140 {"gcse", &flag_gcse, 1,
1141 N_("Perform the global common subexpression elimination") },
1142 {"gcse-lm", &flag_gcse_lm, 1,
1143 N_("Perform enhanced load motion during global subexpression elimination") },
1144 {"gcse-sm", &flag_gcse_sm, 1,
1145 N_("Perform store motion after global subexpression elimination") },
1146 {"branch-target-load-optimize", &flag_branch_target_load_optimize, 1,
1147 N_("Perform branch target load optimization before prologue / epilogue threading") },
1148 {"branch-target-load-optimize2", &flag_branch_target_load_optimize2, 1,
1149 N_("Perform branch target load optimization after prologue / epilogue threading") },
1150 {"loop-optimize", &flag_loop_optimize, 1,
1151 N_("Perform the loop optimizations") },
1152 {"crossjumping", &flag_crossjumping, 1,
1153 N_("Perform cross-jumping optimization") },
1154 {"if-conversion", &flag_if_conversion, 1,
1155 N_("Perform conversion of conditional jumps to branchless equivalents") },
1156 {"if-conversion2", &flag_if_conversion2, 1,
1157 N_("Perform conversion of conditional jumps to conditional execution") },
1158 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1,
1159 N_("Run CSE pass after loop optimizations") },
1160 {"rerun-loop-opt", &flag_rerun_loop_opt, 1,
1161 N_("Run the loop optimizer twice") },
1162 {"delete-null-pointer-checks", &flag_delete_null_pointer_checks, 1,
1163 N_("Delete useless null pointer checks") },
1164 {"schedule-insns", &flag_schedule_insns, 1,
1165 N_("Reschedule instructions before register allocation") },
1166 {"schedule-insns2", &flag_schedule_insns_after_reload, 1,
1167 N_("Reschedule instructions after register allocation") },
1168 {"sched-interblock",&flag_schedule_interblock, 1,
1169 N_("Enable scheduling across basic blocks") },
1170 {"sched-spec",&flag_schedule_speculative, 1,
1171 N_("Allow speculative motion of non-loads") },
1172 {"sched-spec-load",&flag_schedule_speculative_load, 1,
1173 N_("Allow speculative motion of some loads") },
1174 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1,
1175 N_("Allow speculative motion of more loads") },
1176 {"sched2-use-superblocks", &flag_sched2_use_superblocks, 1,
1177 N_("If scheduling post reload, do superblock scheduling") },
1178 {"sched2-use-traces", &flag_sched2_use_traces, 1,
1179 N_("If scheduling post reload, do trace scheduling") },
1180 {"branch-count-reg",&flag_branch_on_count_reg, 1,
1181 N_("Replace add,compare,branch with branch on count reg") },
1182 {"pic", &flag_pic, 1,
1183 N_("Generate position independent code, if possible") },
1184 {"PIC", &flag_pic, 2, ""},
1185 {"pie", &flag_pie, 1,
1186 N_("Generate position independent code for executables, if possible") },
1187 {"PIE", &flag_pie, 2, ""},
1188 {"exceptions", &flag_exceptions, 1,
1189 N_("Enable exception handling") },
1190 {"unwind-tables", &flag_unwind_tables, 1,
1191 N_("Just generate unwind tables for exception handling") },
1192 {"asynchronous-unwind-tables", &flag_asynchronous_unwind_tables, 1,
1193 N_("Generate unwind tables exact at each instruction boundary") },
1194 {"non-call-exceptions", &flag_non_call_exceptions, 1,
1195 N_("Support synchronous non-call exceptions") },
1196 {"profile-arcs", &profile_arc_flag, 1,
1197 N_("Insert arc based program profiling code") },
1198 {"test-coverage", &flag_test_coverage, 1,
1199 N_("Create data files needed by gcov") },
1200 {"branch-probabilities", &flag_branch_probabilities, 1,
1201 N_("Use profiling information for branch probabilities") },
1202 {"profile", &profile_flag, 1,
1203 N_("Enable basic program profiling code") },
1204 {"reorder-blocks", &flag_reorder_blocks, 1,
1205 N_("Reorder basic blocks to improve code placement") },
1206 {"reorder-functions", &flag_reorder_functions, 1,
1207 N_("Reorder functions to improve code placement") },
1208 {"rename-registers", &flag_rename_registers, 1,
1209 N_("Do the register renaming optimization pass") },
1210 {"cprop-registers", &flag_cprop_registers, 1,
1211 N_("Do the register copy-propagation optimization pass") },
1212 {"common", &flag_no_common, 0,
1213 N_("Do not put uninitialized globals in the common section") },
1214 {"inhibit-size-directive", &flag_inhibit_size_directive, 1,
1215 N_("Do not generate .size directives") },
1216 {"function-sections", &flag_function_sections, 1,
1217 N_("place each function into its own section") },
1218 {"data-sections", &flag_data_sections, 1,
1219 N_("place data items into their own section") },
1220 {"verbose-asm", &flag_verbose_asm, 1,
1221 N_("Add extra commentary to assembler output") },
1222 {"gnu-linker", &flag_gnu_linker, 1,
1223 N_("Output GNU ld formatted global initializers") },
1224 {"regmove", &flag_regmove, 1,
1225 N_("Enables a register move optimization") },
1226 {"optimize-register-move", &flag_regmove, 1,
1227 N_("Do the full regmove optimization pass") },
1228 {"pack-struct", &flag_pack_struct, 1,
1229 N_("Pack structure members together without holes") },
1230 {"stack-check", &flag_stack_check, 1,
1231 N_("Insert stack checking code into the program") },
1232 {"argument-alias", &flag_argument_noalias, 0,
1233 N_("Specify that arguments may alias each other & globals") },
1234 {"argument-noalias", &flag_argument_noalias, 1,
1235 N_("Assume arguments may alias globals but not each other") },
1236 {"argument-noalias-global", &flag_argument_noalias, 2,
1237 N_("Assume arguments do not alias each other or globals") },
1238 {"strict-aliasing", &flag_strict_aliasing, 1,
1239 N_("Assume strict aliasing rules apply") },
1240 {"align-loops", &align_loops, 0,
1241 N_("Align the start of loops") },
1242 {"align-jumps", &align_jumps, 0,
1243 N_("Align labels which are only reached by jumping") },
1244 {"align-labels", &align_labels, 0,
1245 N_("Align all labels") },
1246 {"align-functions", &align_functions, 0,
1247 N_("Align the start of functions") },
1248 {"merge-constants", &flag_merge_constants, 1,
1249 N_("Attempt to merge identical constants across compilation units") },
1250 {"merge-all-constants", &flag_merge_constants, 2,
1251 N_("Attempt to merge identical constants and constant variables") },
1252 {"dump-unnumbered", &flag_dump_unnumbered, 1,
1253 N_("Suppress output of instruction numbers and line number notes in debugging dumps") },
1254 {"instrument-functions", &flag_instrument_function_entry_exit, 1,
1255 N_("Instrument function entry/exit with profiling calls") },
1256 {"zero-initialized-in-bss", &flag_zero_initialized_in_bss, 1,
1257 N_("Put zero initialized data in the bss section") },
1258 {"ssa", &flag_ssa, 1,
1259 N_("Enable SSA optimizations") },
1260 {"ssa-ccp", &flag_ssa_ccp, 1,
1261 N_("Enable SSA conditional constant propagation") },
1262 {"ssa-dce", &flag_ssa_dce, 1,
1263 N_("Enable aggressive SSA dead code elimination") },
1264 {"leading-underscore", &flag_leading_underscore, 1,
1265 N_("External symbols have a leading underscore") },
1266 {"ident", &flag_no_ident, 0,
1267 N_("Process #ident directives") },
1268 { "peephole2", &flag_peephole2, 1,
1269 N_("Enables an rtl peephole pass run before sched2") },
1270 {"finite-math-only", &flag_finite_math_only, 1,
1271 N_("Assume no NaNs or +-Infs are generated") },
1272 { "guess-branch-probability", &flag_guess_branch_prob, 1,
1273 N_("Enables guessing of branch probabilities") },
1274 {"math-errno", &flag_errno_math, 1,
1275 N_("Set errno after built-in math functions") },
1276 {"trapping-math", &flag_trapping_math, 1,
1277 N_("Floating-point operations can trap") },
1278 {"unsafe-math-optimizations", &flag_unsafe_math_optimizations, 1,
1279 N_("Allow math optimizations that may violate IEEE or ANSI standards") },
1280 {"signaling-nans", &flag_signaling_nans, 1,
1281 N_("Disable optimizations observable by IEEE signaling NaNs") },
1282 {"bounds-check", &flag_bounds_check, 1,
1283 N_("Generate code to check bounds before indexing arrays") },
1284 {"single-precision-constant", &flag_single_precision_constant, 1,
1285 N_("Convert floating point constant to single precision constant") },
1286 {"time-report", &time_report, 1,
1287 N_("Report time taken by each compiler pass at end of run") },
1288 {"mem-report", &mem_report, 1,
1289 N_("Report on permanent memory allocation at end of run") },
1290 { "trapv", &flag_trapv, 1,
1291 N_("Trap for signed overflow in addition / subtraction / multiplication") },
1292 { "wrapv", &flag_wrapv, 1,
1293 N_("Assume signed arithmetic overflow wraps around") },
1294 { "new-ra", &flag_new_regalloc, 1,
1295 N_("Use graph coloring register allocation.") },
1296 };
1297
1298 /* Table of language-specific options. */
1299
1300 static const struct lang_opt
1301 {
1302 const char *const option;
1303 const char *const description;
1304 }
1305 documented_lang_options[] =
1306 {
1307 /* In order not to overload the --help output, the convention
1308 used here is to only describe those options which are not
1309 enabled by default. */
1310
1311 { "-ansi",
1312 N_("Compile just for ISO C90") },
1313 { "-std= ",
1314 N_("Determine language standard") },
1315
1316 { "-fsigned-bitfields", "" },
1317 { "-funsigned-bitfields",
1318 N_("Make bit-fields by unsigned by default") },
1319 { "-fno-signed-bitfields", "" },
1320 { "-fno-unsigned-bitfields","" },
1321 { "-fsigned-char",
1322 N_("Make 'char' be signed by default") },
1323 { "-funsigned-char",
1324 N_("Make 'char' be unsigned by default") },
1325 { "-fno-signed-char", "" },
1326 { "-fno-unsigned-char", "" },
1327
1328 { "-fasm", "" },
1329 { "-fno-asm",
1330 N_("Do not recognize the 'asm' keyword") },
1331 { "-fbuiltin", "" },
1332 { "-fno-builtin",
1333 N_("Do not recognize any built in functions") },
1334 { "-fhosted",
1335 N_("Assume normal C execution environment") },
1336 { "-fno-hosted", "" },
1337 { "-ffreestanding",
1338 N_("Assume that standard libraries & main might not exist") },
1339 { "-fno-freestanding", "" },
1340 { "-fcond-mismatch",
1341 N_("Allow different types as args of ? operator") },
1342 { "-fno-cond-mismatch", "" },
1343 { "-fdollars-in-identifiers",
1344 N_("Allow the use of $ inside identifiers") },
1345 { "-fno-dollars-in-identifiers", "" },
1346 { "-fpreprocessed", "" },
1347 { "-fno-preprocessed", "" },
1348 { "-fshort-double",
1349 N_("Use the same size for double as for float") },
1350 { "-fno-short-double", "" },
1351 { "-fshort-enums",
1352 N_("Use the smallest fitting integer to hold enums") },
1353 { "-fno-short-enums", "" },
1354 { "-fshort-wchar",
1355 N_("Override the underlying type for wchar_t to `unsigned short'") },
1356 { "-fno-short-wchar", "" },
1357
1358 { "-Wall",
1359 N_("Enable most warning messages") },
1360 { "-Wbad-function-cast",
1361 N_("Warn about casting functions to incompatible types") },
1362 { "-Wno-bad-function-cast", "" },
1363 { "-Wmissing-format-attribute",
1364 N_("Warn about functions which might be candidates for format attributes") },
1365 { "-Wno-missing-format-attribute", "" },
1366 { "-Wcast-qual",
1367 N_("Warn about casts which discard qualifiers") },
1368 { "-Wno-cast-qual", "" },
1369 { "-Wchar-subscripts",
1370 N_("Warn about subscripts whose type is 'char'") },
1371 { "-Wno-char-subscripts", "" },
1372 { "-Wcomment",
1373 N_("Warn if nested comments are detected") },
1374 { "-Wno-comment", "" },
1375 { "-Wcomments",
1376 N_("Warn if nested comments are detected") },
1377 { "-Wno-comments", "" },
1378 { "-Wconversion",
1379 N_("Warn about possibly confusing type conversions") },
1380 { "-Wno-conversion", "" },
1381 { "-Wdiv-by-zero", "" },
1382 { "-Wno-div-by-zero",
1383 N_("Do not warn about compile-time integer division by zero") },
1384 { "-Wfloat-equal",
1385 N_("Warn about testing equality of floating point numbers") },
1386 { "-Wno-float-equal", "" },
1387 { "-Wformat",
1388 N_("Warn about printf/scanf/strftime/strfmon format anomalies") },
1389 { "-Wno-format", "" },
1390 { "-Wformat-extra-args", "" },
1391 { "-Wno-format-extra-args",
1392 N_("Don't warn about too many arguments to format functions") },
1393 { "-Wformat-nonliteral",
1394 N_("Warn about non-string-literal format strings") },
1395 { "-Wno-format-nonliteral", "" },
1396 { "-Wformat-security",
1397 N_("Warn about possible security problems with format functions") },
1398 { "-Wno-format-security", "" },
1399 { "-Wformat-y2k", "" },
1400 { "-Wno-format-y2k",
1401 N_("Don't warn about strftime formats yielding 2 digit years") },
1402 { "-Wimplicit-function-declaration",
1403 N_("Warn about implicit function declarations") },
1404 { "-Wno-implicit-function-declaration", "" },
1405 { "-Werror-implicit-function-declaration", "" },
1406 { "-Wimplicit-int",
1407 N_("Warn when a declaration does not specify a type") },
1408 { "-Wno-implicit-int", "" },
1409 { "-Wimplicit", "" },
1410 { "-Wno-implicit", "" },
1411 { "-Wimport",
1412 N_("Warn about the use of the #import directive") },
1413 { "-Wno-import", "" },
1414 { "-Winvalid-pch",
1415 N_("Warn about PCH files that are found but not used") },
1416 { "-Wlong-long","" },
1417 { "-Wno-long-long",
1418 N_("Do not warn about using 'long long' when -pedantic") },
1419 { "-Wmain",
1420 N_("Warn about suspicious declarations of main") },
1421 { "-Wno-main", "" },
1422 { "-Wmissing-braces",
1423 N_("Warn about possibly missing braces around initializers") },
1424 { "-Wno-missing-braces", "" },
1425 { "-Wmissing-declarations",
1426 N_("Warn about global funcs without previous declarations") },
1427 { "-Wno-missing-declarations", "" },
1428 { "-Wmissing-prototypes",
1429 N_("Warn about global funcs without prototypes") },
1430 { "-Wno-missing-prototypes", "" },
1431 { "-Wmultichar",
1432 N_("Warn about use of multicharacter literals") },
1433 { "-Wno-multichar", "" },
1434 { "-Wnested-externs",
1435 N_("Warn about externs not at file scope level") },
1436 { "-Wno-nested-externs", "" },
1437 { "-Wparentheses",
1438 N_("Warn about possible missing parentheses") },
1439 { "-Wno-parentheses", "" },
1440 { "-Wpointer-arith",
1441 N_("Warn about function pointer arithmetic") },
1442 { "-Wno-pointer-arith", "" },
1443 { "-Wredundant-decls",
1444 N_("Warn about multiple declarations of the same object") },
1445 { "-Wno-redundant-decls", "" },
1446 { "-Wreturn-type",
1447 N_("Warn whenever a function's return-type defaults to int") },
1448 { "-Wno-return-type", "" },
1449 { "-Wsequence-point",
1450 N_("Warn about possible violations of sequence point rules") },
1451 { "-Wno-sequence-point", "" },
1452 { "-Wsign-compare",
1453 N_("Warn about signed/unsigned comparisons") },
1454 { "-Wno-sign-compare", "" },
1455 { "-Wstrict-prototypes",
1456 N_("Warn about non-prototyped function decls") },
1457 { "-Wno-strict-prototypes", "" },
1458 { "-Wtraditional",
1459 N_("Warn about constructs whose meanings change in ISO C") },
1460 { "-Wno-traditional", "" },
1461 { "-Wtrigraphs",
1462 N_("Warn when trigraphs are encountered") },
1463 { "-Wno-trigraphs", "" },
1464 { "-Wundef", "" },
1465 { "-Wno-undef", "" },
1466 { "-Wunknown-pragmas",
1467 N_("Warn about unrecognized pragmas") },
1468 { "-Wno-unknown-pragmas", "" },
1469 { "-Wwrite-strings",
1470 N_("Mark strings as 'const char *'") },
1471 { "-Wno-write-strings", "" },
1472
1473 #define DEFINE_LANG_NAME(NAME) { NULL, NAME },
1474
1475 #include "options_.h"
1476
1477 };
1478
1479 /* Here is a table, controlled by the tm.h file, listing each -m switch
1480 and which bits in `target_switches' it should set or clear.
1481 If VALUE is positive, it is bits to set.
1482 If VALUE is negative, -VALUE is bits to clear.
1483 (The sign bit is not used so there is no confusion.) */
1484
1485 static const struct
1486 {
1487 const char *const name;
1488 const int value;
1489 const char *const description;
1490 }
1491 target_switches[] = TARGET_SWITCHES;
1492
1493 /* This table is similar, but allows the switch to have a value. */
1494
1495 #ifdef TARGET_OPTIONS
1496 static const struct
1497 {
1498 const char *const prefix;
1499 const char **const variable;
1500 const char *const description;
1501 const char *const value;
1502 }
1503 target_options[] = TARGET_OPTIONS;
1504 #endif
1505
1506 /* Options controlling warnings. */
1507
1508 /* Nonzero means warn about function definitions that default the return type
1509 or that use a null return and have a return-type other than void. */
1510
1511 int warn_return_type;
1512
1513 /* Used for the -W options array temporarily. */
1514 static int warn_dummy;
1515
1516 /* Like f_options, but for -W. */
1517
1518 static const lang_independent_options W_options[] =
1519 {
1520 {"unused-function", &warn_dummy, 1,
1521 N_("Warn when a function is unused") },
1522 {"unused-label", &warn_dummy, 1,
1523 N_("Warn when a label is unused") },
1524 {"unused-parameter", &warn_dummy, 1,
1525 N_("Warn when a function parameter is unused") },
1526 {"unused-variable", &warn_dummy, 1,
1527 N_("Warn when a variable is unused") },
1528 {"unused-value", &warn_dummy, 1,
1529 N_("Warn when an expression value is unused") },
1530 {"system-headers", &warn_dummy, 1,
1531 N_("Do not suppress warnings from system headers") },
1532 {"error", &warn_dummy, 1,
1533 N_("Treat all warnings as errors") },
1534 {"shadow", &warn_dummy, 1,
1535 N_("Warn when one local variable shadows another") },
1536 {"switch", &warn_dummy, 1,
1537 N_("Warn about enumerated switches, with no default, missing a case") },
1538 {"switch-default", &warn_dummy, 1,
1539 N_("Warn about enumerated switches missing a default case") },
1540 {"switch-enum", &warn_dummy, 1,
1541 N_("Warn about all enumerated switches missing a specific case") },
1542 {"aggregate-return", &warn_dummy, 1,
1543 N_("Warn about returning structures, unions or arrays") },
1544 {"cast-align", &warn_dummy, 1,
1545 N_("Warn about pointer casts which increase alignment") },
1546 {"unreachable-code", &warn_dummy, 1,
1547 N_("Warn about code that will never be executed") },
1548 {"uninitialized", &warn_dummy, 1,
1549 N_("Warn about uninitialized automatic variables") },
1550 {"inline", &warn_dummy, 1,
1551 N_("Warn when an inlined function cannot be inlined") },
1552 {"packed", &warn_dummy, 1,
1553 N_("Warn when the packed attribute has no effect on struct layout") },
1554 {"padded", &warn_dummy, 1,
1555 N_("Warn when padding is required to align struct members") },
1556 {"disabled-optimization", &warn_dummy, 1,
1557 N_("Warn when an optimization pass is disabled") },
1558 {"deprecated-declarations", &warn_dummy, 1,
1559 N_("Warn about uses of __attribute__((deprecated)) declarations") },
1560 {"missing-noreturn", &warn_dummy, 1,
1561 N_("Warn about functions which might be candidates for attribute noreturn") },
1562 {"strict-aliasing", &warn_dummy, 1,
1563 N_ ("Warn about code which might break the strict aliasing rules") }
1564 };
1565
1566 /* Output files for assembler code (real compiler output)
1567 and debugging dumps. */
1568
1569 FILE *asm_out_file;
1570 FILE *aux_info_file;
1571 FILE *rtl_dump_file = NULL;
1572 FILE *cgraph_dump_file = NULL;
1573
1574 /* Set up a default flag_random_seed and local_tick, unless the user
1575 already specified one. */
1576
1577 static void
1578 randomize (void)
1579 {
1580 if (!flag_random_seed)
1581 {
1582 unsigned HOST_WIDE_INT value;
1583 static char random_seed[HOST_BITS_PER_WIDE_INT / 4 + 3];
1584
1585 /* Get some more or less random data. */
1586 #ifdef HAVE_GETTIMEOFDAY
1587 {
1588 struct timeval tv;
1589
1590 gettimeofday (&tv, NULL);
1591 local_tick = tv.tv_sec * 1000 + tv.tv_usec / 1000;
1592 }
1593 #else
1594 {
1595 time_t now = time (NULL);
1596
1597 if (now != (time_t)-1)
1598 local_tick = (unsigned) now;
1599 }
1600 #endif
1601 value = local_tick ^ getpid ();
1602
1603 sprintf (random_seed, HOST_WIDE_INT_PRINT_HEX, value);
1604 flag_random_seed = random_seed;
1605 }
1606 else if (!local_tick)
1607 local_tick = -1;
1608 }
1609
1610
1611 /* Decode the string P as an integral parameter.
1612 If the string is indeed an integer return its numeric value else
1613 issue an Invalid Option error for the option PNAME and return DEFVAL.
1614 If PNAME is zero just return DEFVAL, do not call error. */
1615
1616 int
1617 read_integral_parameter (const char *p, const char *pname, const int defval)
1618 {
1619 const char *endp = p;
1620
1621 while (*endp)
1622 {
1623 if (ISDIGIT (*endp))
1624 endp++;
1625 else
1626 break;
1627 }
1628
1629 if (*endp != 0)
1630 {
1631 if (pname != 0)
1632 error ("invalid option argument `%s'", pname);
1633 return defval;
1634 }
1635
1636 return atoi (p);
1637 }
1638
1639 /* Return the logarithm of X, base 2, considering X unsigned,
1640 if X is a power of 2. Otherwise, returns -1.
1641
1642 This should be used via the `exact_log2' macro. */
1643
1644 int
1645 exact_log2_wide (unsigned HOST_WIDE_INT x)
1646 {
1647 int log = 0;
1648 /* Test for 0 or a power of 2. */
1649 if (x == 0 || x != (x & -x))
1650 return -1;
1651 while ((x >>= 1) != 0)
1652 log++;
1653 return log;
1654 }
1655
1656 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1657 If X is 0, return -1.
1658
1659 This should be used via the floor_log2 macro. */
1660
1661 int
1662 floor_log2_wide (unsigned HOST_WIDE_INT x)
1663 {
1664 int log = -1;
1665 while (x != 0)
1666 log++,
1667 x >>= 1;
1668 return log;
1669 }
1670
1671 /* Handler for fatal signals, such as SIGSEGV. These are transformed
1672 into ICE messages, which is much more user friendly. In case the
1673 error printer crashes, reset the signal to prevent infinite recursion. */
1674
1675 static void
1676 crash_signal (int signo)
1677 {
1678 signal (signo, SIG_DFL);
1679 internal_error ("%s", strsignal (signo));
1680 }
1681
1682 /* Arrange to dump core on error. (The regular error message is still
1683 printed first, except in the case of abort().) */
1684
1685 static void
1686 setup_core_dumping (void)
1687 {
1688 #ifdef SIGABRT
1689 signal (SIGABRT, SIG_DFL);
1690 #endif
1691 #if defined(HAVE_SETRLIMIT)
1692 {
1693 struct rlimit rlim;
1694 if (getrlimit (RLIMIT_CORE, &rlim) != 0)
1695 fatal_error ("getting core file size maximum limit: %m");
1696 rlim.rlim_cur = rlim.rlim_max;
1697 if (setrlimit (RLIMIT_CORE, &rlim) != 0)
1698 fatal_error ("setting core file size limit to maximum: %m");
1699 }
1700 #endif
1701 diagnostic_abort_on_error (global_dc);
1702 }
1703
1704
1705 /* Strip off a legitimate source ending from the input string NAME of
1706 length LEN. Rather than having to know the names used by all of
1707 our front ends, we strip off an ending of a period followed by
1708 up to five characters. (Java uses ".class".) */
1709
1710 void
1711 strip_off_ending (char *name, int len)
1712 {
1713 int i;
1714 for (i = 2; i < 6 && len > i; i++)
1715 {
1716 if (name[len - i] == '.')
1717 {
1718 name[len - i] = '\0';
1719 break;
1720 }
1721 }
1722 }
1723
1724 /* Output a quoted string. */
1725
1726 void
1727 output_quoted_string (FILE *asm_file, const char *string)
1728 {
1729 #ifdef OUTPUT_QUOTED_STRING
1730 OUTPUT_QUOTED_STRING (asm_file, string);
1731 #else
1732 char c;
1733
1734 putc ('\"', asm_file);
1735 while ((c = *string++) != 0)
1736 {
1737 if (ISPRINT (c))
1738 {
1739 if (c == '\"' || c == '\\')
1740 putc ('\\', asm_file);
1741 putc (c, asm_file);
1742 }
1743 else
1744 fprintf (asm_file, "\\%03o", (unsigned char) c);
1745 }
1746 putc ('\"', asm_file);
1747 #endif
1748 }
1749
1750 /* Output a file name in the form wanted by System V. */
1751
1752 void
1753 output_file_directive (FILE *asm_file, const char *input_name)
1754 {
1755 int len = strlen (input_name);
1756 const char *na = input_name + len;
1757
1758 /* NA gets INPUT_NAME sans directory names. */
1759 while (na > input_name)
1760 {
1761 if (IS_DIR_SEPARATOR (na[-1]))
1762 break;
1763 na--;
1764 }
1765
1766 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1767 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
1768 #else
1769 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1770 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1771 #else
1772 fprintf (asm_file, "\t.file\t");
1773 output_quoted_string (asm_file, na);
1774 fputc ('\n', asm_file);
1775 #endif
1776 #endif
1777 }
1778
1779 /* Routine to open a dump file. Return true if the dump file is enabled. */
1780
1781 static int
1782 open_dump_file (enum dump_file_index index, tree decl)
1783 {
1784 char *dump_name;
1785 const char *open_arg;
1786 char seq[16];
1787
1788 if (! dump_file[index].enabled)
1789 return 0;
1790
1791 timevar_push (TV_DUMP);
1792 if (rtl_dump_file != NULL)
1793 fclose (rtl_dump_file);
1794
1795 sprintf (seq, DUMPFILE_FORMAT, index);
1796
1797 if (! dump_file[index].initialized)
1798 {
1799 /* If we've not initialized the files, do so now. */
1800 if (graph_dump_format != no_graph
1801 && dump_file[index].graph_dump_p)
1802 {
1803 dump_name = concat (seq, dump_file[index].extension, NULL);
1804 clean_graph_dump_file (dump_base_name, dump_name);
1805 free (dump_name);
1806 }
1807 dump_file[index].initialized = 1;
1808 open_arg = "w";
1809 }
1810 else
1811 open_arg = "a";
1812
1813 dump_name = concat (dump_base_name, seq,
1814 dump_file[index].extension, NULL);
1815
1816 rtl_dump_file = fopen (dump_name, open_arg);
1817 if (rtl_dump_file == NULL)
1818 fatal_error ("can't open %s: %m", dump_name);
1819
1820 free (dump_name);
1821
1822 if (decl)
1823 fprintf (rtl_dump_file, "\n;; Function %s%s\n\n",
1824 (*lang_hooks.decl_printable_name) (decl, 2),
1825 cfun->function_frequency == FUNCTION_FREQUENCY_HOT
1826 ? " (hot)"
1827 : cfun->function_frequency == FUNCTION_FREQUENCY_UNLIKELY_EXECUTED
1828 ? " (unlikely executed)"
1829 : "");
1830
1831 timevar_pop (TV_DUMP);
1832 return 1;
1833 }
1834
1835 /* Routine to close a dump file. */
1836
1837 static void
1838 close_dump_file (enum dump_file_index index,
1839 void (*func) (FILE *, rtx),
1840 rtx insns)
1841 {
1842 if (! rtl_dump_file)
1843 return;
1844
1845 timevar_push (TV_DUMP);
1846 if (insns
1847 && graph_dump_format != no_graph
1848 && dump_file[index].graph_dump_p)
1849 {
1850 char seq[16];
1851 char *suffix;
1852
1853 sprintf (seq, DUMPFILE_FORMAT, index);
1854 suffix = concat (seq, dump_file[index].extension, NULL);
1855 print_rtl_graph_with_bb (dump_base_name, suffix, insns);
1856 free (suffix);
1857 }
1858
1859 if (func && insns)
1860 func (rtl_dump_file, insns);
1861
1862 fflush (rtl_dump_file);
1863 fclose (rtl_dump_file);
1864
1865 rtl_dump_file = NULL;
1866 timevar_pop (TV_DUMP);
1867 }
1868
1869 /* Do any final processing required for the declarations in VEC, of
1870 which there are LEN. We write out inline functions and variables
1871 that have been deferred until this point, but which are required.
1872 Returns nonzero if anything was put out. */
1873
1874 int
1875 wrapup_global_declarations (tree *vec, int len)
1876 {
1877 tree decl;
1878 int i;
1879 int reconsider;
1880 int output_something = 0;
1881
1882 for (i = 0; i < len; i++)
1883 {
1884 decl = vec[i];
1885
1886 /* We're not deferring this any longer. Assignment is
1887 conditional to avoid needlessly dirtying PCH pages. */
1888 if (DECL_DEFER_OUTPUT (decl) != 0)
1889 DECL_DEFER_OUTPUT (decl) = 0;
1890
1891 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0)
1892 (*lang_hooks.finish_incomplete_decl) (decl);
1893 }
1894
1895 /* Now emit any global variables or functions that we have been
1896 putting off. We need to loop in case one of the things emitted
1897 here references another one which comes earlier in the list. */
1898 do
1899 {
1900 reconsider = 0;
1901 for (i = 0; i < len; i++)
1902 {
1903 decl = vec[i];
1904
1905 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
1906 continue;
1907
1908 /* Don't write out static consts, unless we still need them.
1909
1910 We also keep static consts if not optimizing (for debugging),
1911 unless the user specified -fno-keep-static-consts.
1912 ??? They might be better written into the debug information.
1913 This is possible when using DWARF.
1914
1915 A language processor that wants static constants to be always
1916 written out (even if it is not used) is responsible for
1917 calling rest_of_decl_compilation itself. E.g. the C front-end
1918 calls rest_of_decl_compilation from finish_decl.
1919 One motivation for this is that is conventional in some
1920 environments to write things like:
1921 static const char rcsid[] = "... version string ...";
1922 intending to force the string to be in the executable.
1923
1924 A language processor that would prefer to have unneeded
1925 static constants "optimized away" would just defer writing
1926 them out until here. E.g. C++ does this, because static
1927 constants are often defined in header files.
1928
1929 ??? A tempting alternative (for both C and C++) would be
1930 to force a constant to be written if and only if it is
1931 defined in a main file, as opposed to an include file. */
1932
1933 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl))
1934 {
1935 bool needed = 1;
1936
1937 if (flag_unit_at_a_time
1938 && cgraph_varpool_node (decl)->finalized)
1939 needed = 0;
1940 else if (flag_unit_at_a_time
1941 && (TREE_USED (decl)
1942 || TREE_USED (DECL_ASSEMBLER_NAME (decl))))
1943 /* needed */;
1944 else if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
1945 /* needed */;
1946 else if (DECL_COMDAT (decl))
1947 needed = 0;
1948 else if (TREE_READONLY (decl) && !TREE_PUBLIC (decl)
1949 && (optimize || !flag_keep_static_consts
1950 || DECL_ARTIFICIAL (decl)))
1951 needed = 0;
1952
1953 if (needed)
1954 {
1955 reconsider = 1;
1956 rest_of_decl_compilation (decl, NULL, 1, 1);
1957 }
1958 }
1959
1960 if (TREE_CODE (decl) == FUNCTION_DECL
1961 && DECL_INITIAL (decl) != 0
1962 && DECL_SAVED_INSNS (decl) != 0
1963 && (flag_keep_inline_functions
1964 || (TREE_PUBLIC (decl) && !DECL_COMDAT (decl))
1965 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
1966 {
1967 reconsider = 1;
1968 output_inline_function (decl);
1969 }
1970 }
1971
1972 if (reconsider)
1973 output_something = 1;
1974 }
1975 while (reconsider);
1976
1977 return output_something;
1978 }
1979
1980 /* Issue appropriate warnings for the global declarations in VEC (of
1981 which there are LEN). Output debugging information for them. */
1982
1983 void
1984 check_global_declarations (tree *vec, int len)
1985 {
1986 tree decl;
1987 int i;
1988
1989 for (i = 0; i < len; i++)
1990 {
1991 decl = vec[i];
1992
1993 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
1994 && ! TREE_ASM_WRITTEN (decl))
1995 /* Cancel the RTL for this decl so that, if debugging info
1996 output for global variables is still to come,
1997 this one will be omitted. */
1998 SET_DECL_RTL (decl, NULL_RTX);
1999
2000 /* Warn about any function
2001 declared static but not defined.
2002 We don't warn about variables,
2003 because many programs have static variables
2004 that exist only to get some text into the object file. */
2005 if (TREE_CODE (decl) == FUNCTION_DECL
2006 && (warn_unused_function
2007 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2008 && DECL_INITIAL (decl) == 0
2009 && DECL_EXTERNAL (decl)
2010 && ! DECL_ARTIFICIAL (decl)
2011 && ! TREE_PUBLIC (decl))
2012 {
2013 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2014 pedwarn_with_decl (decl,
2015 "`%s' used but never defined");
2016 else
2017 warning_with_decl (decl,
2018 "`%s' declared `static' but never defined");
2019 /* This symbol is effectively an "extern" declaration now. */
2020 TREE_PUBLIC (decl) = 1;
2021 assemble_external (decl);
2022 }
2023
2024 /* Warn about static fns or vars defined but not used. */
2025 if (((warn_unused_function && TREE_CODE (decl) == FUNCTION_DECL)
2026 || (warn_unused_variable && TREE_CODE (decl) == VAR_DECL))
2027 && ! TREE_USED (decl)
2028 /* The TREE_USED bit for file-scope decls is kept in the identifier,
2029 to handle multiple external decls in different scopes. */
2030 && ! TREE_USED (DECL_NAME (decl))
2031 && ! DECL_EXTERNAL (decl)
2032 && ! TREE_PUBLIC (decl)
2033 /* A volatile variable might be used in some non-obvious way. */
2034 && ! TREE_THIS_VOLATILE (decl)
2035 /* Global register variables must be declared to reserve them. */
2036 && ! (TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl))
2037 /* Otherwise, ask the language. */
2038 && (*lang_hooks.decls.warn_unused_global) (decl))
2039 warning_with_decl (decl, "`%s' defined but not used");
2040
2041 /* Avoid confusing the debug information machinery when there are
2042 errors. */
2043 if (errorcount == 0 && sorrycount == 0)
2044 {
2045 timevar_push (TV_SYMOUT);
2046 (*debug_hooks->global_decl) (decl);
2047 timevar_pop (TV_SYMOUT);
2048 }
2049 }
2050 }
2051
2052 /* Save the current INPUT_LOCATION on the top entry in the
2053 INPUT_FILE_STACK. Push a new entry for FILE and LINE, and set the
2054 INPUT_LOCATION accordingly. */
2055
2056 void
2057 push_srcloc (const char *file, int line)
2058 {
2059 struct file_stack *fs;
2060
2061 fs = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2062 fs->location = input_location;
2063 fs->next = input_file_stack;
2064 input_filename = file;
2065 input_line = line;
2066 input_file_stack = fs;
2067 input_file_stack_tick++;
2068 }
2069
2070 /* Pop the top entry off the stack of presently open source files.
2071 Restore the INPUT_LOCATION from the new topmost entry on the
2072 stack. */
2073
2074 void
2075 pop_srcloc (void)
2076 {
2077 struct file_stack *fs;
2078
2079 fs = input_file_stack;
2080 input_location = fs->location;
2081 input_file_stack = fs->next;
2082 free (fs);
2083 input_file_stack_tick++;
2084 }
2085
2086 /* Compile an entire translation unit. Write a file of assembly
2087 output and various debugging dumps. */
2088
2089 static void
2090 compile_file (void)
2091 {
2092 /* Initialize yet another pass. */
2093
2094 init_final (main_input_filename);
2095 coverage_init (aux_base_name);
2096
2097 timevar_push (TV_PARSE);
2098
2099 /* Call the parser, which parses the entire file (calling
2100 rest_of_compilation for each function). */
2101 (*lang_hooks.parse_file) (set_yydebug);
2102
2103 /* In case there were missing block closers,
2104 get us back to the global binding level. */
2105 (*lang_hooks.clear_binding_stack) ();
2106
2107 /* Compilation is now finished except for writing
2108 what's left of the symbol table output. */
2109 timevar_pop (TV_PARSE);
2110
2111 if (flag_syntax_only)
2112 return;
2113
2114 (*lang_hooks.decls.final_write_globals)();
2115
2116 cgraph_varpool_assemble_pending_decls ();
2117
2118 /* This must occur after the loop to output deferred functions.
2119 Else the coverage initializer would not be emitted if all the
2120 functions in this compilation unit were deferred. */
2121 coverage_finish ();
2122
2123 /* Write out any pending weak symbol declarations. */
2124
2125 weak_finish ();
2126
2127 /* Do dbx symbols. */
2128 timevar_push (TV_SYMOUT);
2129
2130 #ifdef DWARF2_UNWIND_INFO
2131 if (dwarf2out_do_frame ())
2132 dwarf2out_frame_finish ();
2133 #endif
2134
2135 (*debug_hooks->finish) (main_input_filename);
2136 timevar_pop (TV_SYMOUT);
2137
2138 /* Output some stuff at end of file if nec. */
2139
2140 dw2_output_indirect_constants ();
2141
2142 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
2143 {
2144 timevar_push (TV_DUMP);
2145 open_dump_file (DFI_bp, NULL);
2146
2147 end_branch_prob ();
2148
2149 close_dump_file (DFI_bp, NULL, NULL_RTX);
2150 timevar_pop (TV_DUMP);
2151 }
2152
2153 targetm.asm_out.file_end ();
2154
2155 /* Attach a special .ident directive to the end of the file to identify
2156 the version of GCC which compiled this code. The format of the .ident
2157 string is patterned after the ones produced by native SVR4 compilers. */
2158 #ifdef IDENT_ASM_OP
2159 if (!flag_no_ident)
2160 fprintf (asm_out_file, "%s\"GCC: (GNU) %s\"\n",
2161 IDENT_ASM_OP, version_string);
2162 #endif
2163
2164 if (optimize > 0 && open_dump_file (DFI_combine, NULL))
2165 {
2166 timevar_push (TV_DUMP);
2167 dump_combine_total_stats (rtl_dump_file);
2168 close_dump_file (DFI_combine, NULL, NULL_RTX);
2169 timevar_pop (TV_DUMP);
2170 }
2171 }
2172
2173 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2174 and TYPE_DECL nodes.
2175
2176 This does nothing for local (non-static) variables, unless the
2177 variable is a register variable with an ASMSPEC. In that case, or
2178 if the variable is not an automatic, it sets up the RTL and
2179 outputs any assembler code (label definition, storage allocation
2180 and initialization).
2181
2182 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2183 the assembler symbol name to be used. TOP_LEVEL is nonzero
2184 if this declaration is not within a function. */
2185
2186 void
2187 rest_of_decl_compilation (tree decl,
2188 const char *asmspec,
2189 int top_level,
2190 int at_end)
2191 {
2192 /* We deferred calling assemble_alias so that we could collect
2193 other attributes such as visibility. Emit the alias now. */
2194 {
2195 tree alias;
2196 alias = lookup_attribute ("alias", DECL_ATTRIBUTES (decl));
2197 if (alias)
2198 {
2199 alias = TREE_VALUE (TREE_VALUE (alias));
2200 alias = get_identifier (TREE_STRING_POINTER (alias));
2201 assemble_alias (decl, alias);
2202 }
2203 }
2204
2205 /* Forward declarations for nested functions are not "external",
2206 but we need to treat them as if they were. */
2207 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2208 || TREE_CODE (decl) == FUNCTION_DECL)
2209 {
2210 timevar_push (TV_VARCONST);
2211
2212 if (asmspec)
2213 make_decl_rtl (decl, asmspec);
2214
2215 /* Don't output anything when a tentative file-scope definition
2216 is seen. But at end of compilation, do output code for them. */
2217 if (at_end || !DECL_DEFER_OUTPUT (decl))
2218 {
2219 if (flag_unit_at_a_time && !cgraph_global_info_ready
2220 && TREE_CODE (decl) != FUNCTION_DECL && top_level)
2221 cgraph_varpool_finalize_decl (decl);
2222 else
2223 assemble_variable (decl, top_level, at_end, 0);
2224 }
2225
2226 #ifdef ASM_FINISH_DECLARE_OBJECT
2227 if (decl == last_assemble_variable_decl)
2228 {
2229 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
2230 top_level, at_end);
2231 }
2232 #endif
2233
2234 timevar_pop (TV_VARCONST);
2235 }
2236 else if (DECL_REGISTER (decl) && asmspec != 0)
2237 {
2238 if (decode_reg_name (asmspec) >= 0)
2239 {
2240 SET_DECL_RTL (decl, NULL_RTX);
2241 make_decl_rtl (decl, asmspec);
2242 }
2243 else
2244 {
2245 error ("invalid register name `%s' for register variable", asmspec);
2246 DECL_REGISTER (decl) = 0;
2247 if (!top_level)
2248 expand_decl (decl);
2249 }
2250 }
2251 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2252 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2253 && TREE_CODE (decl) == TYPE_DECL)
2254 {
2255 timevar_push (TV_SYMOUT);
2256 dbxout_symbol (decl, 0);
2257 timevar_pop (TV_SYMOUT);
2258 }
2259 #endif
2260 #ifdef SDB_DEBUGGING_INFO
2261 else if (write_symbols == SDB_DEBUG && top_level
2262 && TREE_CODE (decl) == TYPE_DECL)
2263 {
2264 timevar_push (TV_SYMOUT);
2265 sdbout_symbol (decl, 0);
2266 timevar_pop (TV_SYMOUT);
2267 }
2268 #endif
2269 #ifdef DWARF2_DEBUGGING_INFO
2270 else if ((write_symbols == DWARF2_DEBUG
2271 || write_symbols == VMS_AND_DWARF2_DEBUG)
2272 && top_level
2273 && TREE_CODE (decl) == TYPE_DECL)
2274 {
2275 timevar_push (TV_SYMOUT);
2276 dwarf2out_decl (decl);
2277 timevar_pop (TV_SYMOUT);
2278 }
2279 #endif
2280 }
2281
2282 /* Called after finishing a record, union or enumeral type. */
2283
2284 void
2285 rest_of_type_compilation (
2286 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) \
2287 || defined (SDB_DEBUGGING_INFO) || defined (DWARF2_DEBUGGING_INFO)
2288 tree type,
2289 int toplev
2290 #else
2291 tree type ATTRIBUTE_UNUSED,
2292 int toplev ATTRIBUTE_UNUSED
2293 #endif
2294 )
2295 {
2296 /* Avoid confusing the debug information machinery when there are
2297 errors. */
2298 if (errorcount != 0 || sorrycount != 0)
2299 return;
2300
2301 timevar_push (TV_SYMOUT);
2302 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2303 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2304 dbxout_symbol (TYPE_STUB_DECL (type), !toplev);
2305 #endif
2306 #ifdef SDB_DEBUGGING_INFO
2307 if (write_symbols == SDB_DEBUG)
2308 sdbout_symbol (TYPE_STUB_DECL (type), !toplev);
2309 #endif
2310 #ifdef DWARF2_DEBUGGING_INFO
2311 if ((write_symbols == DWARF2_DEBUG
2312 || write_symbols == VMS_AND_DWARF2_DEBUG)
2313 && toplev)
2314 dwarf2out_decl (TYPE_STUB_DECL (type));
2315 #endif
2316 timevar_pop (TV_SYMOUT);
2317 }
2318
2319 /* Turn the RTL into assembly. */
2320 static void
2321 rest_of_handle_final (tree decl, rtx insns)
2322 {
2323 timevar_push (TV_FINAL);
2324 {
2325 rtx x;
2326 const char *fnname;
2327
2328 /* Get the function's name, as described by its RTL. This may be
2329 different from the DECL_NAME name used in the source file. */
2330
2331 x = DECL_RTL (decl);
2332 if (GET_CODE (x) != MEM)
2333 abort ();
2334 x = XEXP (x, 0);
2335 if (GET_CODE (x) != SYMBOL_REF)
2336 abort ();
2337 fnname = XSTR (x, 0);
2338
2339 assemble_start_function (decl, fnname);
2340 final_start_function (insns, asm_out_file, optimize);
2341 final (insns, asm_out_file, optimize, 0);
2342 final_end_function ();
2343
2344 #ifdef IA64_UNWIND_INFO
2345 /* ??? The IA-64 ".handlerdata" directive must be issued before
2346 the ".endp" directive that closes the procedure descriptor. */
2347 output_function_exception_table ();
2348 #endif
2349
2350 assemble_end_function (decl, fnname);
2351
2352 #ifndef IA64_UNWIND_INFO
2353 /* Otherwise, it feels unclean to switch sections in the middle. */
2354 output_function_exception_table ();
2355 #endif
2356
2357 if (! quiet_flag)
2358 fflush (asm_out_file);
2359
2360 /* Release all memory allocated by flow. */
2361 free_basic_block_vars (0);
2362
2363 /* Release all memory held by regsets now. */
2364 regset_release_memory ();
2365 }
2366 timevar_pop (TV_FINAL);
2367
2368 ggc_collect ();
2369 }
2370
2371 #ifdef DELAY_SLOTS
2372 /* Run delay slot optimization. */
2373 static void
2374 rest_of_handle_delay_slots (tree decl, rtx insns)
2375 {
2376 timevar_push (TV_DBR_SCHED);
2377 open_dump_file (DFI_dbr, decl);
2378
2379 dbr_schedule (insns, rtl_dump_file);
2380
2381 close_dump_file (DFI_dbr, print_rtl, insns);
2382 timevar_pop (TV_DBR_SCHED);
2383
2384 ggc_collect ();
2385 }
2386 #endif
2387
2388 #ifdef STACK_REGS
2389 /* Convert register usage from flat register file usage to a stack
2390 register file. */
2391 static void
2392 rest_of_handle_stack_regs (tree decl, rtx insns)
2393 {
2394 timevar_push (TV_REG_STACK);
2395 open_dump_file (DFI_stack, decl);
2396
2397 if (reg_to_stack (insns, rtl_dump_file) && optimize)
2398 {
2399 if (cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK
2400 | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0))
2401 && flag_reorder_blocks)
2402 {
2403 reorder_basic_blocks ();
2404 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK);
2405 }
2406 }
2407
2408 close_dump_file (DFI_stack, print_rtl_with_bb, insns);
2409 timevar_pop (TV_REG_STACK);
2410
2411 ggc_collect ();
2412 }
2413 #endif
2414
2415
2416 /* Machine independent reorg pass. */
2417 static void
2418 rest_of_handle_machine_reorg (tree decl, rtx insns)
2419 {
2420 timevar_push (TV_MACH_DEP);
2421 open_dump_file (DFI_mach, decl);
2422
2423 (*targetm.machine_dependent_reorg) ();
2424
2425 close_dump_file (DFI_mach, print_rtl, insns);
2426 timevar_pop (TV_MACH_DEP);
2427
2428 ggc_collect ();
2429 }
2430
2431
2432 /* Run new register allocator. Return TRUE if we must exit
2433 rest_of_compilation upon return. */
2434 static bool
2435 rest_of_handle_new_regalloc (tree decl, rtx insns, int *rebuild_notes)
2436 {
2437 int failure;
2438
2439 delete_trivially_dead_insns (insns, max_reg_num ());
2440 reg_alloc ();
2441
2442 timevar_pop (TV_LOCAL_ALLOC);
2443 if (dump_file[DFI_lreg].enabled)
2444 {
2445 timevar_push (TV_DUMP);
2446
2447 close_dump_file (DFI_lreg, NULL, NULL);
2448 timevar_pop (TV_DUMP);
2449 }
2450
2451 /* XXX clean up the whole mess to bring live info in shape again. */
2452 timevar_push (TV_GLOBAL_ALLOC);
2453 open_dump_file (DFI_greg, decl);
2454
2455 build_insn_chain (insns);
2456 failure = reload (insns, 0);
2457
2458 timevar_pop (TV_GLOBAL_ALLOC);
2459
2460 if (dump_file[DFI_greg].enabled)
2461 {
2462 timevar_push (TV_DUMP);
2463
2464 dump_global_regs (rtl_dump_file);
2465
2466 close_dump_file (DFI_greg, print_rtl_with_bb, insns);
2467 timevar_pop (TV_DUMP);
2468 }
2469
2470 if (failure)
2471 return true;
2472
2473 reload_completed = 1;
2474 *rebuild_notes = 0;
2475
2476 return false;
2477 }
2478
2479 /* Run old register allocator. Return TRUE if we must exit
2480 rest_of_compilation upon return. */
2481 static bool
2482 rest_of_handle_old_regalloc (tree decl, rtx insns, int *rebuild_notes)
2483 {
2484 int failure;
2485
2486 /* Allocate the reg_renumber array. */
2487 allocate_reg_info (max_regno, FALSE, TRUE);
2488
2489 /* And the reg_equiv_memory_loc array. */
2490 reg_equiv_memory_loc = (rtx *) xcalloc (max_regno, sizeof (rtx));
2491
2492 allocate_initial_values (reg_equiv_memory_loc);
2493
2494 regclass (insns, max_reg_num (), rtl_dump_file);
2495 *rebuild_notes = local_alloc ();
2496
2497 timevar_pop (TV_LOCAL_ALLOC);
2498
2499 if (dump_file[DFI_lreg].enabled)
2500 {
2501 timevar_push (TV_DUMP);
2502
2503 dump_flow_info (rtl_dump_file);
2504 dump_local_alloc (rtl_dump_file);
2505
2506 close_dump_file (DFI_lreg, print_rtl_with_bb, insns);
2507 timevar_pop (TV_DUMP);
2508 }
2509
2510 ggc_collect ();
2511
2512 timevar_push (TV_GLOBAL_ALLOC);
2513 open_dump_file (DFI_greg, decl);
2514
2515 /* If optimizing, allocate remaining pseudo-regs. Do the reload
2516 pass fixing up any insns that are invalid. */
2517
2518 if (optimize)
2519 failure = global_alloc (rtl_dump_file);
2520 else
2521 {
2522 build_insn_chain (insns);
2523 failure = reload (insns, 0);
2524 }
2525
2526 timevar_pop (TV_GLOBAL_ALLOC);
2527
2528 if (dump_file[DFI_greg].enabled)
2529 {
2530 timevar_push (TV_DUMP);
2531
2532 dump_global_regs (rtl_dump_file);
2533
2534 close_dump_file (DFI_greg, print_rtl_with_bb, insns);
2535 timevar_pop (TV_DUMP);
2536 }
2537
2538 return failure;
2539 }
2540
2541 /* Run the regrename and cprop passes. */
2542 static void
2543 rest_of_handle_regrename (tree decl, rtx insns)
2544 {
2545 timevar_push (TV_RENAME_REGISTERS);
2546 open_dump_file (DFI_rnreg, decl);
2547
2548 if (flag_rename_registers)
2549 regrename_optimize ();
2550 if (flag_cprop_registers)
2551 copyprop_hardreg_forward ();
2552
2553 close_dump_file (DFI_rnreg, print_rtl_with_bb, insns);
2554 timevar_pop (TV_RENAME_REGISTERS);
2555 }
2556
2557 /* Reorder basic blocks. */
2558 static void
2559 rest_of_handle_reorder_blocks (tree decl, rtx insns)
2560 {
2561 timevar_push (TV_REORDER_BLOCKS);
2562 open_dump_file (DFI_bbro, decl);
2563
2564 /* Last attempt to optimize CFG, as scheduling, peepholing and insn
2565 splitting possibly introduced more crossjumping opportunities. */
2566 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE
2567 | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0));
2568
2569 if (flag_sched2_use_traces && flag_schedule_insns_after_reload)
2570 tracer ();
2571 if (flag_reorder_blocks)
2572 reorder_basic_blocks ();
2573 if (flag_reorder_blocks
2574 || (flag_sched2_use_traces && flag_schedule_insns_after_reload))
2575 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
2576
2577 close_dump_file (DFI_bbro, print_rtl_with_bb, insns);
2578 timevar_pop (TV_REORDER_BLOCKS);
2579 }
2580
2581 #ifdef INSN_SCHEDULING
2582 /* Run instruction scheduler. */
2583 static void
2584 rest_of_handle_sched (tree decl, rtx insns)
2585 {
2586 timevar_push (TV_SCHED);
2587
2588 /* Print function header into sched dump now
2589 because doing the sched analysis makes some of the dump. */
2590 if (optimize > 0 && flag_schedule_insns)
2591 {
2592 open_dump_file (DFI_sched, decl);
2593
2594 /* Do control and data sched analysis,
2595 and write some of the results to dump file. */
2596
2597 schedule_insns (rtl_dump_file);
2598
2599 close_dump_file (DFI_sched, print_rtl_with_bb, insns);
2600 }
2601 timevar_pop (TV_SCHED);
2602
2603 ggc_collect ();
2604 }
2605
2606 /* Run second scheduling pass after reload. */
2607 static void
2608 rest_of_handle_sched2 (tree decl, rtx insns)
2609 {
2610 timevar_push (TV_SCHED2);
2611 open_dump_file (DFI_sched2, decl);
2612
2613 /* Do control and data sched analysis again,
2614 and write some more of the results to dump file. */
2615
2616 split_all_insns (1);
2617
2618 if (flag_sched2_use_superblocks || flag_sched2_use_traces)
2619 {
2620 schedule_ebbs (rtl_dump_file);
2621 /* No liveness updating code yet, but it should be easy to do.
2622 reg-stack recompute the liveness when needed for now. */
2623 count_or_remove_death_notes (NULL, 1);
2624 cleanup_cfg (CLEANUP_EXPENSIVE);
2625 }
2626 else
2627 schedule_insns (rtl_dump_file);
2628
2629 close_dump_file (DFI_sched2, print_rtl_with_bb, insns);
2630 timevar_pop (TV_SCHED2);
2631
2632 ggc_collect ();
2633 }
2634 #endif
2635
2636 /* Register allocation pre-pass, to reduce number of moves necessary
2637 for two-address machines. */
2638 static void
2639 rest_of_handle_regmove (tree decl, rtx insns)
2640 {
2641 timevar_push (TV_REGMOVE);
2642 open_dump_file (DFI_regmove, decl);
2643
2644 regmove_optimize (insns, max_reg_num (), rtl_dump_file);
2645
2646 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
2647 close_dump_file (DFI_regmove, print_rtl_with_bb, insns);
2648 timevar_pop (TV_REGMOVE);
2649
2650 ggc_collect ();
2651 }
2652
2653 /* Run tracer. */
2654 static void
2655 rest_of_handle_tracer (tree decl, rtx insns)
2656 {
2657 timevar_push (TV_TRACER);
2658 open_dump_file (DFI_tracer, decl);
2659 if (rtl_dump_file)
2660 dump_flow_info (rtl_dump_file);
2661 tracer ();
2662 cleanup_cfg (CLEANUP_EXPENSIVE);
2663 reg_scan (insns, max_reg_num (), 0);
2664 close_dump_file (DFI_tracer, print_rtl_with_bb, get_insns ());
2665 timevar_pop (TV_TRACER);
2666 }
2667
2668 /* If-conversion and CFG cleanup. */
2669 static void
2670 rest_of_handle_if_conversion (tree decl, rtx insns)
2671 {
2672 open_dump_file (DFI_ce1, decl);
2673 if (flag_if_conversion)
2674 {
2675 timevar_push (TV_IFCVT);
2676 if (rtl_dump_file)
2677 dump_flow_info (rtl_dump_file);
2678 cleanup_cfg (CLEANUP_EXPENSIVE);
2679 reg_scan (insns, max_reg_num (), 0);
2680 if_convert (0);
2681 timevar_pop (TV_IFCVT);
2682 }
2683 timevar_push (TV_JUMP);
2684 cleanup_cfg (CLEANUP_EXPENSIVE);
2685 reg_scan (insns, max_reg_num (), 0);
2686 timevar_pop (TV_JUMP);
2687 close_dump_file (DFI_ce1, print_rtl_with_bb, get_insns ());
2688 }
2689
2690 /* Rerun if-conversion, as combine may have simplified things enough
2691 to now meet sequence length restrictions. */
2692 static void
2693 rest_of_handle_if_after_combine (tree decl, rtx insns)
2694 {
2695 timevar_push (TV_IFCVT);
2696 open_dump_file (DFI_ce2, decl);
2697
2698 no_new_pseudos = 0;
2699 if_convert (1);
2700 no_new_pseudos = 1;
2701
2702 close_dump_file (DFI_ce2, print_rtl_with_bb, insns);
2703 timevar_pop (TV_IFCVT);
2704 }
2705
2706 /* Do branch profiling and static profile estimation passes. */
2707 static void
2708 rest_of_handle_branch_prob (tree decl, rtx insns)
2709 {
2710 struct loops loops;
2711
2712 timevar_push (TV_BRANCH_PROB);
2713 open_dump_file (DFI_bp, decl);
2714 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
2715 branch_prob ();
2716
2717 /* Discover and record the loop depth at the head of each basic
2718 block. The loop infrastructure does the real job for us. */
2719 flow_loops_find (&loops, LOOP_TREE);
2720
2721 if (rtl_dump_file)
2722 flow_loops_dump (&loops, rtl_dump_file, NULL, 0);
2723
2724 /* Estimate using heuristics if no profiling info is available. */
2725 if (flag_guess_branch_prob)
2726 estimate_probability (&loops);
2727
2728 flow_loops_free (&loops);
2729 close_dump_file (DFI_bp, print_rtl_with_bb, insns);
2730 timevar_pop (TV_BRANCH_PROB);
2731 }
2732
2733 /* Do control and data flow analysis; write some of the results to the
2734 dump file. */
2735 static void
2736 rest_of_handle_cfg (tree decl, rtx insns)
2737 {
2738 open_dump_file (DFI_cfg, decl);
2739 if (rtl_dump_file)
2740 dump_flow_info (rtl_dump_file);
2741 if (optimize)
2742 cleanup_cfg (CLEANUP_EXPENSIVE
2743 | (flag_thread_jumps ? CLEANUP_THREADING : 0));
2744
2745 /* It may make more sense to mark constant functions after dead code is
2746 eliminated by life_analysis, but we need to do it early, as -fprofile-arcs
2747 may insert code making function non-constant, but we still must consider
2748 it as constant, otherwise -fbranch-probabilities will not read data back.
2749
2750 life_analysis rarely eliminates modification of external memory.
2751 */
2752 if (optimize)
2753 mark_constant_function ();
2754
2755 close_dump_file (DFI_cfg, print_rtl_with_bb, insns);
2756 }
2757
2758 /* Purge addressofs. */
2759 static void
2760 rest_of_handle_addresof (tree decl, rtx insns)
2761 {
2762 open_dump_file (DFI_addressof, decl);
2763
2764 purge_addressof (insns);
2765 if (optimize)
2766 purge_all_dead_edges (0);
2767 reg_scan (insns, max_reg_num (), 1);
2768
2769 close_dump_file (DFI_addressof, print_rtl, insns);
2770 }
2771
2772 /* We may have potential sibling or tail recursion sites. Select one
2773 (of possibly multiple) methods of performing the call. */
2774 static void
2775 rest_of_handle_sibling_calls (rtx insns)
2776 {
2777 rtx insn;
2778 optimize_sibling_and_tail_recursive_calls ();
2779
2780 /* Recompute the CFG as sibling optimization clobbers it randomly. */
2781 free_bb_for_insn ();
2782 find_exception_handler_labels ();
2783 rebuild_jump_labels (insns);
2784 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2785
2786 /* There is pass ordering problem - we must lower NOTE_INSN_PREDICTION
2787 notes before simplifying cfg and we must do lowering after sibcall
2788 that unhides parts of RTL chain and cleans up the CFG.
2789
2790 Until sibcall is replaced by tree-level optimizer, lets just
2791 sweep away the NOTE_INSN_PREDICTION notes that leaked out. */
2792 for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
2793 if (GET_CODE (insn) == NOTE
2794 && NOTE_LINE_NUMBER (insn) == NOTE_INSN_PREDICTION)
2795 delete_insn (insn);
2796
2797 close_dump_file (DFI_sibling, print_rtl, get_insns ());
2798 }
2799
2800 /* Perform jump bypassing and control flow optimizations. */
2801 static void
2802 rest_of_handle_jump_bypass (tree decl, rtx insns)
2803 {
2804 timevar_push (TV_BYPASS);
2805 open_dump_file (DFI_bypass, decl);
2806
2807 cleanup_cfg (CLEANUP_EXPENSIVE);
2808
2809 if (bypass_jumps (rtl_dump_file))
2810 {
2811 rebuild_jump_labels (insns);
2812 cleanup_cfg (CLEANUP_EXPENSIVE);
2813 delete_trivially_dead_insns (insns, max_reg_num ());
2814 }
2815
2816 close_dump_file (DFI_bypass, print_rtl_with_bb, insns);
2817 timevar_pop (TV_BYPASS);
2818
2819 ggc_collect ();
2820
2821 #ifdef ENABLE_CHECKING
2822 verify_flow_info ();
2823 #endif
2824 }
2825
2826 /* Handle inlining of functions in rest_of_compilation. Return TRUE
2827 if we must exit rest_of_compilation upon return. */
2828 static bool
2829 rest_of_handle_inlining (tree decl)
2830 {
2831 rtx insns;
2832 int inlinable = 0;
2833 tree parent;
2834 const char *lose;
2835
2836 /* If we are reconsidering an inline function at the end of
2837 compilation, skip the stuff for making it inline. */
2838 if (DECL_SAVED_INSNS (decl) != 0)
2839 return 0;
2840
2841 /* If this is nested inside an inlined external function, pretend
2842 it was only declared. Since we cannot inline such functions,
2843 generating code for this one is not only not necessary but will
2844 confuse some debugging output writers. */
2845 for (parent = DECL_CONTEXT (current_function_decl);
2846 parent != NULL_TREE;
2847 parent = get_containing_scope (parent))
2848 if (TREE_CODE (parent) == FUNCTION_DECL
2849 && DECL_INLINE (parent) && DECL_EXTERNAL (parent))
2850 {
2851 DECL_INITIAL (decl) = 0;
2852 return true;
2853 }
2854 else if (TYPE_P (parent))
2855 /* A function in a local class should be treated normally. */
2856 break;
2857
2858 /* If requested, consider whether to make this function inline. */
2859 if ((DECL_INLINE (decl) && !flag_no_inline)
2860 || flag_inline_functions)
2861 {
2862 timevar_push (TV_INTEGRATION);
2863 lose = function_cannot_inline_p (decl);
2864 timevar_pop (TV_INTEGRATION);
2865 if (lose || ! optimize)
2866 {
2867 if (warn_inline && DECL_INLINE (decl))
2868 warning_with_decl (decl, lose);
2869 DECL_ABSTRACT_ORIGIN (decl) = 0;
2870 /* Don't really compile an extern inline function.
2871 If we can't make it inline, pretend
2872 it was only declared. */
2873 if (DECL_EXTERNAL (decl))
2874 {
2875 DECL_INITIAL (decl) = 0;
2876 return true;
2877 }
2878 }
2879 else {
2880 /* ??? Note that we used to just make it look like if
2881 the "inline" keyword was specified when we decide
2882 to inline it (because of -finline-functions).
2883 garloff@suse.de, 2002-04-24: Add another flag to
2884 actually record this piece of information. */
2885 if (!DECL_INLINE (decl))
2886 DID_INLINE_FUNC (decl) = 1;
2887 inlinable = DECL_INLINE (decl) = 1;
2888 }
2889 }
2890
2891 insns = get_insns ();
2892
2893 /* Dump the rtl code if we are dumping rtl. */
2894
2895 if (open_dump_file (DFI_rtl, decl))
2896 {
2897 if (DECL_SAVED_INSNS (decl))
2898 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2899 close_dump_file (DFI_rtl, print_rtl, insns);
2900 }
2901
2902 /* Convert from NOTE_INSN_EH_REGION style notes, and do other
2903 sorts of eh initialization. Delay this until after the
2904 initial rtl dump so that we can see the original nesting. */
2905 convert_from_eh_region_ranges ();
2906
2907 /* If function is inline, and we don't yet know whether to
2908 compile it by itself, defer decision till end of compilation.
2909 wrapup_global_declarations will (indirectly) call
2910 rest_of_compilation again for those functions that need to
2911 be output. Also defer those functions that we are supposed
2912 to defer. */
2913
2914 if (inlinable
2915 || (DECL_INLINE (decl)
2916 && flag_inline_functions
2917 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2918 && ! TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))
2919 && ! flag_keep_inline_functions)
2920 || DECL_EXTERNAL (decl))))
2921 DECL_DEFER_OUTPUT (decl) = 1;
2922
2923 if (DECL_INLINE (decl))
2924 /* DWARF wants separate debugging info for abstract and
2925 concrete instances of all inline functions, including those
2926 declared inline but not inlined, and those inlined even
2927 though they weren't declared inline. Conveniently, that's
2928 what DECL_INLINE means at this point. */
2929 (*debug_hooks->deferred_inline_function) (decl);
2930
2931 if (DECL_DEFER_OUTPUT (decl))
2932 {
2933 /* If -Wreturn-type, we have to do a bit of compilation. We just
2934 want to call cleanup the cfg to figure out whether or not we can
2935 fall off the end of the function; we do the minimum amount of
2936 work necessary to make that safe. */
2937 if (warn_return_type)
2938 {
2939 int saved_optimize = optimize;
2940
2941 optimize = 0;
2942 rebuild_jump_labels (insns);
2943 find_exception_handler_labels ();
2944 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2945 cleanup_cfg (CLEANUP_PRE_SIBCALL | CLEANUP_PRE_LOOP);
2946 optimize = saved_optimize;
2947
2948 /* CFG is no longer maintained up-to-date. */
2949 free_bb_for_insn ();
2950 }
2951
2952 set_nothrow_function_flags ();
2953 if (current_function_nothrow)
2954 /* Now we know that this can't throw; set the flag for the benefit
2955 of other functions later in this translation unit. */
2956 TREE_NOTHROW (current_function_decl) = 1;
2957
2958 timevar_push (TV_INTEGRATION);
2959 save_for_inline (decl);
2960 timevar_pop (TV_INTEGRATION);
2961 DECL_SAVED_INSNS (decl)->inlinable = inlinable;
2962 return true;
2963 }
2964
2965 /* If specified extern inline but we aren't inlining it, we are
2966 done. This goes for anything that gets here with DECL_EXTERNAL
2967 set, not just things with DECL_INLINE. */
2968 return (bool) DECL_EXTERNAL (decl);
2969 }
2970
2971 /* Rest of compilation helper to convert the rtl to SSA form. */
2972 static rtx
2973 rest_of_handle_ssa (tree decl, rtx insns)
2974 {
2975 timevar_push (TV_TO_SSA);
2976 open_dump_file (DFI_ssa, decl);
2977
2978 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2979 convert_to_ssa ();
2980
2981 close_dump_file (DFI_ssa, print_rtl_with_bb, insns);
2982 timevar_pop (TV_TO_SSA);
2983
2984 /* Perform sparse conditional constant propagation, if requested. */
2985 if (flag_ssa_ccp)
2986 {
2987 timevar_push (TV_SSA_CCP);
2988 open_dump_file (DFI_ssa_ccp, decl);
2989
2990 ssa_const_prop ();
2991
2992 close_dump_file (DFI_ssa_ccp, print_rtl_with_bb, get_insns ());
2993 timevar_pop (TV_SSA_CCP);
2994 }
2995
2996 /* It would be useful to cleanup the CFG at this point, but block
2997 merging and possibly other transformations might leave a PHI
2998 node in the middle of a basic block, which is a strict no-no. */
2999
3000 /* The SSA implementation uses basic block numbers in its phi
3001 nodes. Thus, changing the control-flow graph or the basic
3002 blocks, e.g., calling find_basic_blocks () or cleanup_cfg (),
3003 may cause problems. */
3004
3005 if (flag_ssa_dce)
3006 {
3007 /* Remove dead code. */
3008
3009 timevar_push (TV_SSA_DCE);
3010 open_dump_file (DFI_ssa_dce, decl);
3011
3012 insns = get_insns ();
3013 ssa_eliminate_dead_code ();
3014
3015 close_dump_file (DFI_ssa_dce, print_rtl_with_bb, insns);
3016 timevar_pop (TV_SSA_DCE);
3017 }
3018
3019 /* Convert from SSA form. */
3020
3021 timevar_push (TV_FROM_SSA);
3022 open_dump_file (DFI_ussa, decl);
3023
3024 convert_from_ssa ();
3025 /* New registers have been created. Rescan their usage. */
3026 reg_scan (insns, max_reg_num (), 1);
3027
3028 close_dump_file (DFI_ussa, print_rtl_with_bb, insns);
3029 timevar_pop (TV_FROM_SSA);
3030
3031 ggc_collect ();
3032
3033 return insns;
3034 }
3035
3036 /* Try to identify useless null pointer tests and delete them. */
3037 static void
3038 rest_of_handle_null_pointer (tree decl, rtx insns)
3039 {
3040 open_dump_file (DFI_null, decl);
3041 if (rtl_dump_file)
3042 dump_flow_info (rtl_dump_file);
3043
3044 if (delete_null_pointer_checks (insns))
3045 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
3046
3047 close_dump_file (DFI_null, print_rtl_with_bb, insns);
3048 }
3049
3050 /* Try combining insns through substitution. */
3051 static void
3052 rest_of_handle_combine (tree decl, rtx insns)
3053 {
3054 int rebuild_jump_labels_after_combine = 0;
3055
3056 timevar_push (TV_COMBINE);
3057 open_dump_file (DFI_combine, decl);
3058
3059 rebuild_jump_labels_after_combine
3060 = combine_instructions (insns, max_reg_num ());
3061
3062 /* Combining insns may have turned an indirect jump into a
3063 direct jump. Rebuild the JUMP_LABEL fields of jumping
3064 instructions. */
3065 if (rebuild_jump_labels_after_combine)
3066 {
3067 timevar_push (TV_JUMP);
3068 rebuild_jump_labels (insns);
3069 timevar_pop (TV_JUMP);
3070
3071 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
3072 }
3073
3074 close_dump_file (DFI_combine, print_rtl_with_bb, insns);
3075 timevar_pop (TV_COMBINE);
3076
3077 ggc_collect ();
3078 }
3079
3080 /* Perform life analysis. */
3081 static void
3082 rest_of_handle_life (tree decl, rtx insns)
3083 {
3084 open_dump_file (DFI_life, decl);
3085 regclass_init ();
3086
3087 #ifdef ENABLE_CHECKING
3088 verify_flow_info ();
3089 #endif
3090 life_analysis (insns, rtl_dump_file, PROP_FINAL);
3091 if (optimize)
3092 cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0) | CLEANUP_UPDATE_LIFE
3093 | (flag_thread_jumps ? CLEANUP_THREADING : 0));
3094 timevar_pop (TV_FLOW);
3095
3096 if (warn_uninitialized)
3097 {
3098 uninitialized_vars_warning (DECL_INITIAL (decl));
3099 if (extra_warnings)
3100 setjmp_args_warning ();
3101 }
3102
3103 if (optimize)
3104 {
3105 if (!flag_new_regalloc && initialize_uninitialized_subregs ())
3106 {
3107 /* Insns were inserted, and possibly pseudos created, so
3108 things might look a bit different. */
3109 insns = get_insns ();
3110 allocate_reg_life_data ();
3111 update_life_info (NULL, UPDATE_LIFE_GLOBAL_RM_NOTES,
3112 PROP_LOG_LINKS | PROP_REG_INFO | PROP_DEATH_NOTES);
3113 }
3114 }
3115
3116 no_new_pseudos = 1;
3117
3118 close_dump_file (DFI_life, print_rtl_with_bb, insns);
3119
3120 ggc_collect ();
3121 }
3122
3123 /* Perform common subexpression elimination. Nonzero value from
3124 `cse_main' means that jumps were simplified and some code may now
3125 be unreachable, so do jump optimization again. */
3126 static void
3127 rest_of_handle_cse (tree decl, rtx insns)
3128 {
3129 int tem;
3130
3131 open_dump_file (DFI_cse, decl);
3132 if (rtl_dump_file)
3133 dump_flow_info (rtl_dump_file);
3134 timevar_push (TV_CSE);
3135
3136 reg_scan (insns, max_reg_num (), 1);
3137
3138 tem = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
3139 if (tem)
3140 rebuild_jump_labels (insns);
3141 purge_all_dead_edges (0);
3142
3143 delete_trivially_dead_insns (insns, max_reg_num ());
3144
3145 /* If we are not running more CSE passes, then we are no longer
3146 expecting CSE to be run. But always rerun it in a cheap mode. */
3147 cse_not_expected = !flag_rerun_cse_after_loop && !flag_gcse;
3148
3149 if (tem || optimize > 1)
3150 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
3151 /* Try to identify useless null pointer tests and delete them. */
3152 if (flag_delete_null_pointer_checks)
3153 {
3154 timevar_push (TV_JUMP);
3155
3156 if (delete_null_pointer_checks (insns))
3157 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
3158 timevar_pop (TV_JUMP);
3159 }
3160
3161 /* The second pass of jump optimization is likely to have
3162 removed a bunch more instructions. */
3163 renumber_insns (rtl_dump_file);
3164
3165 timevar_pop (TV_CSE);
3166 close_dump_file (DFI_cse, print_rtl_with_bb, insns);
3167 }
3168
3169 /* Run second CSE pass after loop optimizations. */
3170 static void
3171 rest_of_handle_cse2 (tree decl, rtx insns)
3172 {
3173 int tem;
3174
3175 timevar_push (TV_CSE2);
3176 open_dump_file (DFI_cse2, decl);
3177 if (rtl_dump_file)
3178 dump_flow_info (rtl_dump_file);
3179 /* CFG is no longer maintained up-to-date. */
3180 tem = cse_main (insns, max_reg_num (), 1, rtl_dump_file);
3181 purge_all_dead_edges (0);
3182 delete_trivially_dead_insns (insns, max_reg_num ());
3183
3184 if (tem)
3185 {
3186 timevar_push (TV_JUMP);
3187 rebuild_jump_labels (insns);
3188 cleanup_cfg (CLEANUP_EXPENSIVE);
3189 timevar_pop (TV_JUMP);
3190 }
3191 reg_scan (insns, max_reg_num (), 0);
3192 close_dump_file (DFI_cse2, print_rtl_with_bb, insns);
3193 ggc_collect ();
3194 timevar_pop (TV_CSE2);
3195 }
3196
3197 /* Perform global cse. */
3198 static void
3199 rest_of_handle_gcse (tree decl, rtx insns)
3200 {
3201 int save_csb, save_cfj;
3202 int tem2 = 0, tem;
3203
3204 timevar_push (TV_GCSE);
3205 open_dump_file (DFI_gcse, decl);
3206
3207 tem = gcse_main (insns, rtl_dump_file);
3208 rebuild_jump_labels (insns);
3209 delete_trivially_dead_insns (insns, max_reg_num ());
3210
3211 save_csb = flag_cse_skip_blocks;
3212 save_cfj = flag_cse_follow_jumps;
3213 flag_cse_skip_blocks = flag_cse_follow_jumps = 0;
3214
3215 /* Instantiate any remaining CONSTANT_P_RTX nodes. */
3216 if (current_function_calls_constant_p)
3217 purge_builtin_constant_p ();
3218
3219 /* If -fexpensive-optimizations, re-run CSE to clean up things done
3220 by gcse. */
3221 if (flag_expensive_optimizations)
3222 {
3223 timevar_push (TV_CSE);
3224 reg_scan (insns, max_reg_num (), 1);
3225 tem2 = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
3226 purge_all_dead_edges (0);
3227 delete_trivially_dead_insns (insns, max_reg_num ());
3228 timevar_pop (TV_CSE);
3229 cse_not_expected = !flag_rerun_cse_after_loop;
3230 }
3231
3232 /* If gcse or cse altered any jumps, rerun jump optimizations to clean
3233 things up. Then possibly re-run CSE again. */
3234 while (tem || tem2)
3235 {
3236 tem = tem2 = 0;
3237 timevar_push (TV_JUMP);
3238 rebuild_jump_labels (insns);
3239 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
3240 timevar_pop (TV_JUMP);
3241
3242 if (flag_expensive_optimizations)
3243 {
3244 timevar_push (TV_CSE);
3245 reg_scan (insns, max_reg_num (), 1);
3246 tem2 = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
3247 purge_all_dead_edges (0);
3248 delete_trivially_dead_insns (insns, max_reg_num ());
3249 timevar_pop (TV_CSE);
3250 }
3251 }
3252
3253 close_dump_file (DFI_gcse, print_rtl_with_bb, insns);
3254 timevar_pop (TV_GCSE);
3255
3256 ggc_collect ();
3257 flag_cse_skip_blocks = save_csb;
3258 flag_cse_follow_jumps = save_cfj;
3259 #ifdef ENABLE_CHECKING
3260 verify_flow_info ();
3261 #endif
3262 }
3263
3264 /* Move constant computations out of loops. */
3265 static void
3266 rest_of_handle_loop_optimize (tree decl, rtx insns)
3267 {
3268 int do_unroll, do_prefetch;
3269
3270 timevar_push (TV_LOOP);
3271 delete_dead_jumptables ();
3272 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
3273 open_dump_file (DFI_loop, decl);
3274
3275 /* CFG is no longer maintained up-to-date. */
3276 free_bb_for_insn ();
3277
3278 if (flag_unroll_loops)
3279 do_unroll = 0; /* Having two unrollers is useless. */
3280 else
3281 do_unroll = flag_old_unroll_loops ? LOOP_UNROLL : LOOP_AUTO_UNROLL;
3282 do_prefetch = flag_prefetch_loop_arrays ? LOOP_PREFETCH : 0;
3283
3284 if (flag_rerun_loop_opt)
3285 {
3286 cleanup_barriers ();
3287
3288 /* We only want to perform unrolling once. */
3289 loop_optimize (insns, rtl_dump_file, do_unroll);
3290 do_unroll = 0;
3291
3292 /* The first call to loop_optimize makes some instructions
3293 trivially dead. We delete those instructions now in the
3294 hope that doing so will make the heuristics in loop work
3295 better and possibly speed up compilation. */
3296 delete_trivially_dead_insns (insns, max_reg_num ());
3297
3298 /* The regscan pass is currently necessary as the alias
3299 analysis code depends on this information. */
3300 reg_scan (insns, max_reg_num (), 1);
3301 }
3302 cleanup_barriers ();
3303 loop_optimize (insns, rtl_dump_file, do_unroll | LOOP_BCT | do_prefetch);
3304
3305 /* Loop can create trivially dead instructions. */
3306 delete_trivially_dead_insns (insns, max_reg_num ());
3307 close_dump_file (DFI_loop, print_rtl, insns);
3308 timevar_pop (TV_LOOP);
3309 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3310
3311 ggc_collect ();
3312 }
3313
3314 /* Perform loop optimizations. It might be better to do them a bit
3315 sooner, but we want the profile feedback to work more
3316 efficiently. */
3317 static void
3318 rest_of_handle_loop2 (tree decl, rtx insns)
3319 {
3320 struct loops *loops;
3321 timevar_push (TV_LOOP);
3322 open_dump_file (DFI_loop2, decl);
3323 if (rtl_dump_file)
3324 dump_flow_info (rtl_dump_file);
3325
3326 loops = loop_optimizer_init (rtl_dump_file);
3327
3328 if (loops)
3329 {
3330 /* The optimizations: */
3331 if (flag_unswitch_loops)
3332 unswitch_loops (loops);
3333
3334 if (flag_peel_loops || flag_unroll_loops)
3335 unroll_and_peel_loops (loops,
3336 (flag_peel_loops ? UAP_PEEL : 0) |
3337 (flag_unroll_loops ? UAP_UNROLL : 0) |
3338 (flag_unroll_all_loops ? UAP_UNROLL_ALL : 0));
3339
3340 loop_optimizer_finalize (loops, rtl_dump_file);
3341 }
3342
3343 cleanup_cfg (CLEANUP_EXPENSIVE);
3344 delete_trivially_dead_insns (insns, max_reg_num ());
3345 reg_scan (insns, max_reg_num (), 0);
3346 if (rtl_dump_file)
3347 dump_flow_info (rtl_dump_file);
3348 close_dump_file (DFI_loop2, print_rtl_with_bb, get_insns ());
3349 timevar_pop (TV_LOOP);
3350 ggc_collect ();
3351 }
3352
3353 /* This is called from finish_function (within langhooks.parse_file)
3354 after each top-level definition is parsed.
3355 It is supposed to compile that function or variable
3356 and output the assembler code for it.
3357 After we return, the tree storage is freed. */
3358
3359 void
3360 rest_of_compilation (tree decl)
3361 {
3362 rtx insns;
3363 int rebuild_label_notes_after_reload;
3364
3365 timevar_push (TV_REST_OF_COMPILATION);
3366
3367 /* Register rtl specific functions for cfg. */
3368 rtl_register_cfg_hooks ();
3369
3370 /* Now that we're out of the frontend, we shouldn't have any more
3371 CONCATs anywhere. */
3372 generating_concat_p = 0;
3373
3374 /* When processing delayed functions, prepare_function_start() won't
3375 have been run to re-initialize it. */
3376 cse_not_expected = ! optimize;
3377
3378 /* First, make sure that NOTE_BLOCK is set correctly for each
3379 NOTE_INSN_BLOCK_BEG/NOTE_INSN_BLOCK_END note. */
3380 if (!cfun->x_whole_function_mode_p)
3381 identify_blocks ();
3382
3383 /* In function-at-a-time mode, we do not attempt to keep the BLOCK
3384 tree in sensible shape. So, we just recalculate it here. */
3385 if (cfun->x_whole_function_mode_p)
3386 reorder_blocks ();
3387
3388 init_flow ();
3389
3390 if (rest_of_handle_inlining (decl))
3391 goto exit_rest_of_compilation;
3392
3393 /* If we're emitting a nested function, make sure its parent gets
3394 emitted as well. Doing otherwise confuses debug info. */
3395 {
3396 tree parent;
3397 for (parent = DECL_CONTEXT (current_function_decl);
3398 parent != NULL_TREE;
3399 parent = get_containing_scope (parent))
3400 if (TREE_CODE (parent) == FUNCTION_DECL)
3401 TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (parent)) = 1;
3402 }
3403
3404 /* We are now committed to emitting code for this function. Do any
3405 preparation, such as emitting abstract debug info for the inline
3406 before it gets mangled by optimization. */
3407 if (DECL_INLINE (decl))
3408 (*debug_hooks->outlining_inline_function) (decl);
3409
3410 /* Remove any notes we don't need. That will make iterating
3411 over the instruction sequence faster, and allow the garbage
3412 collector to reclaim the memory used by the notes. */
3413 remove_unnecessary_notes ();
3414 reorder_blocks ();
3415
3416 ggc_collect ();
3417
3418 /* Initialize some variables used by the optimizers. */
3419 init_function_for_compilation ();
3420
3421 if (! DECL_DEFER_OUTPUT (decl))
3422 TREE_ASM_WRITTEN (decl) = 1;
3423
3424 /* Now that integrate will no longer see our rtl, we need not
3425 distinguish between the return value of this function and the
3426 return value of called functions. Also, we can remove all SETs
3427 of subregs of hard registers; they are only here because of
3428 integrate. Also, we can now initialize pseudos intended to
3429 carry magic hard reg data throughout the function. */
3430 rtx_equal_function_value_matters = 0;
3431 purge_hard_subreg_sets (get_insns ());
3432
3433 /* Early return if there were errors. We can run afoul of our
3434 consistency checks, and there's not really much point in fixing them.
3435 Don't return yet if -Wreturn-type; we need to do cleanup_cfg. */
3436 if (((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
3437 || errorcount || sorrycount)
3438 goto exit_rest_of_compilation;
3439
3440 timevar_push (TV_JUMP);
3441 open_dump_file (DFI_sibling, decl);
3442 insns = get_insns ();
3443 rebuild_jump_labels (insns);
3444 find_exception_handler_labels ();
3445 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3446
3447 delete_unreachable_blocks ();
3448
3449 /* We have to issue these warnings now already, because CFG cleanups
3450 further down may destroy the required information. */
3451 check_function_return_warnings ();
3452
3453 /* Turn NOTE_INSN_PREDICTIONs into branch predictions. */
3454 if (flag_guess_branch_prob)
3455 {
3456 timevar_push (TV_BRANCH_PROB);
3457 note_prediction_to_br_prob ();
3458 timevar_pop (TV_BRANCH_PROB);
3459 }
3460
3461 if (flag_optimize_sibling_calls)
3462 rest_of_handle_sibling_calls (insns);
3463
3464 timevar_pop (TV_JUMP);
3465
3466 insn_locators_initialize ();
3467 /* Complete generation of exception handling code. */
3468 if (doing_eh (0))
3469 {
3470 timevar_push (TV_JUMP);
3471 open_dump_file (DFI_eh, decl);
3472
3473 finish_eh_generation ();
3474
3475 close_dump_file (DFI_eh, print_rtl, get_insns ());
3476 timevar_pop (TV_JUMP);
3477 }
3478
3479 /* Delay emitting hard_reg_initial_value sets until after EH landing pad
3480 generation, which might create new sets. */
3481 emit_initial_value_sets ();
3482
3483 #ifdef FINALIZE_PIC
3484 /* If we are doing position-independent code generation, now
3485 is the time to output special prologues and epilogues.
3486 We do not want to do this earlier, because it just clutters
3487 up inline functions with meaningless insns. */
3488 if (flag_pic)
3489 FINALIZE_PIC;
3490 #endif
3491
3492 insns = get_insns ();
3493
3494 /* Copy any shared structure that should not be shared. */
3495 unshare_all_rtl (current_function_decl, insns);
3496
3497 #ifdef SETJMP_VIA_SAVE_AREA
3498 /* This must be performed before virtual register instantiation.
3499 Please be aware the everything in the compiler that can look
3500 at the RTL up to this point must understand that REG_SAVE_AREA
3501 is just like a use of the REG contained inside. */
3502 if (current_function_calls_alloca)
3503 optimize_save_area_alloca (insns);
3504 #endif
3505
3506 /* Instantiate all virtual registers. */
3507 instantiate_virtual_regs (current_function_decl, insns);
3508
3509 open_dump_file (DFI_jump, decl);
3510
3511 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
3512 are initialized and to compute whether control can drop off the end
3513 of the function. */
3514
3515 timevar_push (TV_JUMP);
3516 /* Turn NOTE_INSN_EXPECTED_VALUE into REG_BR_PROB. Do this
3517 before jump optimization switches branch directions. */
3518 if (flag_guess_branch_prob)
3519 expected_value_to_br_prob ();
3520
3521 reg_scan (insns, max_reg_num (), 0);
3522 rebuild_jump_labels (insns);
3523 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3524 delete_trivially_dead_insns (insns, max_reg_num ());
3525 if (rtl_dump_file)
3526 dump_flow_info (rtl_dump_file);
3527 cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0) | CLEANUP_PRE_LOOP
3528 | (flag_thread_jumps ? CLEANUP_THREADING : 0));
3529
3530 if (optimize)
3531 {
3532 free_bb_for_insn ();
3533 copy_loop_headers (insns);
3534 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3535 }
3536 purge_line_number_notes (insns);
3537
3538 timevar_pop (TV_JUMP);
3539 close_dump_file (DFI_jump, print_rtl, insns);
3540
3541 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
3542 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
3543 goto exit_rest_of_compilation;
3544
3545 /* Long term, this should probably move before the jump optimizer too,
3546 but I didn't want to disturb the rtl_dump_and_exit and related
3547 stuff at this time. */
3548 if (optimize > 0 && flag_ssa)
3549 insns = rest_of_handle_ssa (decl, insns);
3550
3551 timevar_push (TV_JUMP);
3552
3553 if (optimize)
3554 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
3555
3556 if (flag_delete_null_pointer_checks)
3557 rest_of_handle_null_pointer (decl, insns);
3558
3559 /* Jump optimization, and the removal of NULL pointer checks, may
3560 have reduced the number of instructions substantially. CSE, and
3561 future passes, allocate arrays whose dimensions involve the
3562 maximum instruction UID, so if we can reduce the maximum UID
3563 we'll save big on memory. */
3564 renumber_insns (rtl_dump_file);
3565 timevar_pop (TV_JUMP);
3566
3567 close_dump_file (DFI_jump, print_rtl_with_bb, insns);
3568
3569 ggc_collect ();
3570
3571 if (optimize > 0)
3572 rest_of_handle_cse (decl, insns);
3573
3574 rest_of_handle_addresof (decl, insns);
3575
3576 ggc_collect ();
3577
3578 if (optimize > 0)
3579 {
3580 if (flag_gcse)
3581 rest_of_handle_gcse (decl, insns);
3582
3583 if (flag_loop_optimize)
3584 rest_of_handle_loop_optimize (decl, insns);
3585
3586 if (flag_gcse)
3587 rest_of_handle_jump_bypass (decl, insns);
3588 }
3589
3590 timevar_push (TV_FLOW);
3591
3592 rest_of_handle_cfg (decl, insns);
3593
3594 if (optimize > 0
3595 || profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
3596 rest_of_handle_branch_prob (decl, insns);
3597
3598 if (optimize > 0)
3599 rest_of_handle_if_conversion (decl, insns);
3600
3601 if (flag_tracer)
3602 rest_of_handle_tracer (decl, insns);
3603
3604 if (optimize > 0
3605 && (flag_unswitch_loops
3606 || flag_peel_loops
3607 || flag_unroll_loops))
3608 rest_of_handle_loop2 (decl, insns);
3609
3610 if (flag_rerun_cse_after_loop)
3611 rest_of_handle_cse2 (decl, insns);
3612
3613 cse_not_expected = 1;
3614
3615 rest_of_handle_life (decl, insns);
3616
3617 if (optimize > 0)
3618 rest_of_handle_combine (decl, insns);
3619
3620 if (flag_if_conversion)
3621 rest_of_handle_if_after_combine (decl, insns);
3622
3623 if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
3624 rest_of_handle_regmove (decl, insns);
3625
3626 /* Do unconditional splitting before register allocation to allow machine
3627 description to add extra information not needed previously. */
3628 split_all_insns (1);
3629
3630 #ifdef OPTIMIZE_MODE_SWITCHING
3631 timevar_push (TV_MODE_SWITCH);
3632
3633 no_new_pseudos = 0;
3634 optimize_mode_switching (NULL);
3635 no_new_pseudos = 1;
3636
3637 timevar_pop (TV_MODE_SWITCH);
3638 #endif
3639
3640 /* Any of the several passes since flow1 will have munged register
3641 lifetime data a bit. We need it to be up to date for scheduling
3642 (see handling of reg_known_equiv in init_alias_analysis). */
3643 recompute_reg_usage (insns, !optimize_size);
3644
3645 #ifdef INSN_SCHEDULING
3646 rest_of_handle_sched (decl, insns);
3647 #endif
3648
3649 /* Determine if the current function is a leaf before running reload
3650 since this can impact optimizations done by the prologue and
3651 epilogue thus changing register elimination offsets. */
3652 current_function_is_leaf = leaf_function_p ();
3653
3654 timevar_push (TV_LOCAL_ALLOC);
3655 open_dump_file (DFI_lreg, decl);
3656
3657 if (flag_new_regalloc)
3658 {
3659 if (rest_of_handle_new_regalloc (decl, insns,
3660 &rebuild_label_notes_after_reload))
3661 goto exit_rest_of_compilation;
3662 }
3663 else
3664 {
3665 if (rest_of_handle_old_regalloc (decl, insns,
3666 &rebuild_label_notes_after_reload))
3667 goto exit_rest_of_compilation;
3668 }
3669
3670 ggc_collect ();
3671
3672 open_dump_file (DFI_postreload, decl);
3673
3674 /* Do a very simple CSE pass over just the hard registers. */
3675 if (optimize > 0)
3676 {
3677 timevar_push (TV_RELOAD_CSE_REGS);
3678 reload_cse_regs (insns);
3679 timevar_pop (TV_RELOAD_CSE_REGS);
3680 }
3681
3682 /* Register allocation and reloading may have turned an indirect jump into
3683 a direct jump. If so, we must rebuild the JUMP_LABEL fields of
3684 jumping instructions. */
3685 if (rebuild_label_notes_after_reload)
3686 {
3687 timevar_push (TV_JUMP);
3688
3689 rebuild_jump_labels (insns);
3690 purge_all_dead_edges (0);
3691
3692 timevar_pop (TV_JUMP);
3693 }
3694
3695 close_dump_file (DFI_postreload, print_rtl_with_bb, insns);
3696
3697 /* Re-create the death notes which were deleted during reload. */
3698 timevar_push (TV_FLOW2);
3699 open_dump_file (DFI_flow2, decl);
3700
3701 #ifdef ENABLE_CHECKING
3702 verify_flow_info ();
3703 #endif
3704
3705 /* If optimizing, then go ahead and split insns now. */
3706 #ifndef STACK_REGS
3707 if (optimize > 0)
3708 #endif
3709 split_all_insns (0);
3710
3711 if (flag_branch_target_load_optimize)
3712 {
3713 open_dump_file (DFI_branch_target_load, decl);
3714
3715 branch_target_load_optimize (insns, false);
3716
3717 close_dump_file (DFI_branch_target_load, print_rtl_with_bb, insns);
3718
3719 ggc_collect ();
3720 }
3721
3722 if (optimize)
3723 cleanup_cfg (CLEANUP_EXPENSIVE);
3724
3725 /* On some machines, the prologue and epilogue code, or parts thereof,
3726 can be represented as RTL. Doing so lets us schedule insns between
3727 it and the rest of the code and also allows delayed branch
3728 scheduling to operate in the epilogue. */
3729 thread_prologue_and_epilogue_insns (insns);
3730 epilogue_completed = 1;
3731
3732 if (optimize)
3733 {
3734 life_analysis (insns, rtl_dump_file, PROP_FINAL);
3735 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE
3736 | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0));
3737
3738 /* This is kind of a heuristic. We need to run combine_stack_adjustments
3739 even for machines with possibly nonzero RETURN_POPS_ARGS
3740 and ACCUMULATE_OUTGOING_ARGS. We expect that only ports having
3741 push instructions will have popping returns. */
3742 #ifndef PUSH_ROUNDING
3743 if (!ACCUMULATE_OUTGOING_ARGS)
3744 #endif
3745 combine_stack_adjustments ();
3746
3747 ggc_collect ();
3748 }
3749
3750 flow2_completed = 1;
3751
3752 close_dump_file (DFI_flow2, print_rtl_with_bb, insns);
3753 timevar_pop (TV_FLOW2);
3754
3755 #ifdef HAVE_peephole2
3756 if (optimize > 0 && flag_peephole2)
3757 {
3758 timevar_push (TV_PEEPHOLE2);
3759 open_dump_file (DFI_peephole2, decl);
3760
3761 peephole2_optimize (rtl_dump_file);
3762
3763 close_dump_file (DFI_peephole2, print_rtl_with_bb, insns);
3764 timevar_pop (TV_PEEPHOLE2);
3765 }
3766 #endif
3767
3768 if (optimize > 0)
3769 {
3770 if (flag_rename_registers || flag_cprop_registers)
3771 rest_of_handle_regrename (decl, insns);
3772
3773 rest_of_handle_reorder_blocks (decl, insns);
3774 }
3775
3776 if (flag_if_conversion2)
3777 {
3778 timevar_push (TV_IFCVT2);
3779 open_dump_file (DFI_ce3, decl);
3780
3781 if_convert (1);
3782
3783 close_dump_file (DFI_ce3, print_rtl_with_bb, insns);
3784 timevar_pop (TV_IFCVT2);
3785 }
3786
3787 if (flag_branch_target_load_optimize2)
3788 {
3789 /* Leave this a warning for now so that it is possible to experiment
3790 with running this pass twice. In 3.6, we should either make this
3791 an error, or use separate dump files. */
3792 if (flag_branch_target_load_optimize)
3793 warning ("branch target register load optimization is not intended "
3794 "to be run twice");
3795
3796 open_dump_file (DFI_branch_target_load, decl);
3797
3798 branch_target_load_optimize (insns, true);
3799
3800 close_dump_file (DFI_branch_target_load, print_rtl_with_bb, insns);
3801
3802 ggc_collect ();
3803 }
3804
3805 #ifdef INSN_SCHEDULING
3806 if (optimize > 0 && flag_schedule_insns_after_reload)
3807 rest_of_handle_sched2 (decl, insns);
3808 #endif
3809
3810 #ifdef LEAF_REGISTERS
3811 current_function_uses_only_leaf_regs
3812 = optimize > 0 && only_leaf_regs_used () && leaf_function_p ();
3813 #endif
3814
3815 #ifdef STACK_REGS
3816 rest_of_handle_stack_regs (decl, insns);
3817 #endif
3818
3819 compute_alignments ();
3820
3821 /* CFG is no longer maintained up-to-date. */
3822 free_bb_for_insn ();
3823
3824 if (targetm.machine_dependent_reorg != 0)
3825 rest_of_handle_machine_reorg (decl, insns);
3826
3827 purge_line_number_notes (insns);
3828 cleanup_barriers ();
3829
3830 #ifdef DELAY_SLOTS
3831 if (optimize > 0 && flag_delayed_branch)
3832 rest_of_handle_delay_slots (decl, insns);
3833 #endif
3834
3835 #if defined (HAVE_ATTR_length) && !defined (STACK_REGS)
3836 timevar_push (TV_SHORTEN_BRANCH);
3837 split_all_insns_noflow ();
3838 timevar_pop (TV_SHORTEN_BRANCH);
3839 #endif
3840
3841 convert_to_eh_region_ranges ();
3842
3843 /* Shorten branches. */
3844 timevar_push (TV_SHORTEN_BRANCH);
3845 shorten_branches (get_insns ());
3846 timevar_pop (TV_SHORTEN_BRANCH);
3847
3848 set_nothrow_function_flags ();
3849 if (current_function_nothrow)
3850 /* Now we know that this can't throw; set the flag for the benefit
3851 of other functions later in this translation unit. */
3852 TREE_NOTHROW (current_function_decl) = 1;
3853
3854 rest_of_handle_final (decl, insns);
3855
3856 /* Write DBX symbols if requested. */
3857
3858 /* Note that for those inline functions where we don't initially
3859 know for certain that we will be generating an out-of-line copy,
3860 the first invocation of this routine (rest_of_compilation) will
3861 skip over this code by doing a `goto exit_rest_of_compilation;'.
3862 Later on, wrapup_global_declarations will (indirectly) call
3863 rest_of_compilation again for those inline functions that need
3864 to have out-of-line copies generated. During that call, we
3865 *will* be routed past here. */
3866
3867 timevar_push (TV_SYMOUT);
3868 (*debug_hooks->function_decl) (decl);
3869 timevar_pop (TV_SYMOUT);
3870
3871 exit_rest_of_compilation:
3872
3873 coverage_end_function ();
3874
3875 /* In case the function was not output,
3876 don't leave any temporary anonymous types
3877 queued up for sdb output. */
3878 #ifdef SDB_DEBUGGING_INFO
3879 if (write_symbols == SDB_DEBUG)
3880 sdbout_types (NULL_TREE);
3881 #endif
3882
3883 reload_completed = 0;
3884 epilogue_completed = 0;
3885 flow2_completed = 0;
3886 no_new_pseudos = 0;
3887
3888 timevar_push (TV_FINAL);
3889
3890 /* Clear out the insn_length contents now that they are no
3891 longer valid. */
3892 init_insn_lengths ();
3893
3894 /* Show no temporary slots allocated. */
3895 init_temp_slots ();
3896
3897 free_basic_block_vars (0);
3898 free_bb_for_insn ();
3899
3900 timevar_pop (TV_FINAL);
3901
3902 if ((*targetm.binds_local_p) (current_function_decl))
3903 {
3904 int pref = cfun->preferred_stack_boundary;
3905 if (cfun->recursive_call_emit
3906 && cfun->stack_alignment_needed > cfun->preferred_stack_boundary)
3907 pref = cfun->stack_alignment_needed;
3908 cgraph_rtl_info (current_function_decl)->preferred_incoming_stack_boundary
3909 = pref;
3910 }
3911
3912 /* Make sure volatile mem refs aren't considered valid operands for
3913 arithmetic insns. We must call this here if this is a nested inline
3914 function, since the above code leaves us in the init_recog state
3915 (from final.c), and the function context push/pop code does not
3916 save/restore volatile_ok.
3917
3918 ??? Maybe it isn't necessary for expand_start_function to call this
3919 anymore if we do it here? */
3920
3921 init_recog_no_volatile ();
3922
3923 /* We're done with this function. Free up memory if we can. */
3924 free_after_parsing (cfun);
3925 if (! DECL_DEFER_OUTPUT (decl))
3926 {
3927 free_after_compilation (cfun);
3928
3929 /* Clear integrate.c's pointer to the cfun structure we just
3930 destroyed. */
3931 DECL_SAVED_INSNS (decl) = 0;
3932 }
3933 cfun = 0;
3934
3935 ggc_collect ();
3936
3937 timevar_pop (TV_REST_OF_COMPILATION);
3938 }
3939
3940 /* Display help for generic options. */
3941 void
3942 display_help (void)
3943 {
3944 int undoc;
3945 unsigned long i;
3946 const char *lang;
3947
3948 for (i = ARRAY_SIZE (f_options); i--;)
3949 {
3950 const char *description = f_options[i].description;
3951
3952 if (description != NULL && *description != 0)
3953 printf (" -f%-21s %s\n",
3954 f_options[i].string, _(description));
3955 }
3956
3957 for (i = LAST_PARAM; i--;)
3958 {
3959 const char *description = compiler_params[i].help;
3960 const int length = 21 - strlen (compiler_params[i].option);
3961
3962 if (description != NULL && *description != 0)
3963 printf (" --param %s=<value>%.*s%s\n",
3964 compiler_params[i].option,
3965 length > 0 ? length : 1, " ",
3966 _(description));
3967 }
3968
3969 for (i = ARRAY_SIZE (W_options); i--;)
3970 {
3971 const char *description = W_options[i].description;
3972
3973 if (description != NULL && *description != 0)
3974 printf (" -W%-21s %s\n",
3975 W_options[i].string, _(description));
3976 }
3977
3978 for (i = ARRAY_SIZE (debug_args); i--;)
3979 {
3980 if (debug_args[i].description != NULL)
3981 printf (" -g%-21s %s\n",
3982 debug_args[i].arg, _(debug_args[i].description));
3983 }
3984
3985 undoc = 0;
3986 lang = "language";
3987
3988 /* Display descriptions of language specific options.
3989 If there is no description, note that there is an undocumented option.
3990 If the description is empty, do not display anything. (This allows
3991 options to be deliberately undocumented, for whatever reason).
3992 If the option string is missing, then this is a marker, indicating
3993 that the description string is in fact the name of a language, whose
3994 language specific options are to follow. */
3995
3996 if (ARRAY_SIZE (documented_lang_options) > 1)
3997 {
3998 printf (_("\nLanguage specific options:\n"));
3999
4000 for (i = 0; i < ARRAY_SIZE (documented_lang_options); i++)
4001 {
4002 const char *description = documented_lang_options[i].description;
4003 const char *option = documented_lang_options[i].option;
4004
4005 if (description == NULL)
4006 {
4007 undoc = 1;
4008
4009 if (extra_warnings)
4010 printf (_(" %-23.23s [undocumented]\n"), option);
4011 }
4012 else if (*description == 0)
4013 continue;
4014 else if (option == NULL)
4015 {
4016 if (undoc)
4017 printf
4018 (_("\nThere are undocumented %s specific options as well.\n"),
4019 lang);
4020 undoc = 0;
4021
4022 printf (_("\n Options for %s:\n"), description);
4023
4024 lang = description;
4025 }
4026 else
4027 printf (" %-23.23s %s\n", option, _(description));
4028 }
4029 }
4030
4031 if (undoc)
4032 printf (_("\nThere are undocumented %s specific options as well.\n"),
4033 lang);
4034
4035 display_target_options ();
4036 }
4037
4038 /* Display help for target options. */
4039 void
4040 display_target_options (void)
4041 {
4042 int undoc, i;
4043 static bool displayed = false;
4044
4045 /* Avoid double printing for --help --target-help. */
4046 if (displayed)
4047 return;
4048
4049 displayed = true;
4050
4051 if (ARRAY_SIZE (target_switches) > 1
4052 #ifdef TARGET_OPTIONS
4053 || ARRAY_SIZE (target_options) > 1
4054 #endif
4055 )
4056 {
4057 int doc = 0;
4058
4059 undoc = 0;
4060
4061 printf (_("\nTarget specific options:\n"));
4062
4063 for (i = ARRAY_SIZE (target_switches); i--;)
4064 {
4065 const char *option = target_switches[i].name;
4066 const char *description = target_switches[i].description;
4067
4068 if (option == NULL || *option == 0)
4069 continue;
4070 else if (description == NULL)
4071 {
4072 undoc = 1;
4073
4074 if (extra_warnings)
4075 printf (_(" -m%-23.23s [undocumented]\n"), option);
4076 }
4077 else if (*description != 0)
4078 doc += printf (" -m%-23.23s %s\n", option, _(description));
4079 }
4080
4081 #ifdef TARGET_OPTIONS
4082 for (i = ARRAY_SIZE (target_options); i--;)
4083 {
4084 const char *option = target_options[i].prefix;
4085 const char *description = target_options[i].description;
4086
4087 if (option == NULL || *option == 0)
4088 continue;
4089 else if (description == NULL)
4090 {
4091 undoc = 1;
4092
4093 if (extra_warnings)
4094 printf (_(" -m%-23.23s [undocumented]\n"), option);
4095 }
4096 else if (*description != 0)
4097 doc += printf (" -m%-23.23s %s\n", option, _(description));
4098 }
4099 #endif
4100 if (undoc)
4101 {
4102 if (doc)
4103 printf (_("\nThere are undocumented target specific options as well.\n"));
4104 else
4105 printf (_(" They exist, but they are not documented.\n"));
4106 }
4107 }
4108 }
4109
4110 /* Parse a -d... command line switch. */
4111
4112 void
4113 decode_d_option (const char *arg)
4114 {
4115 int i, c, matched;
4116
4117 while (*arg)
4118 switch (c = *arg++)
4119 {
4120 case 'a':
4121 for (i = 0; i < (int) DFI_MAX; ++i)
4122 dump_file[i].enabled = 1;
4123 break;
4124 case 'A':
4125 flag_debug_asm = 1;
4126 break;
4127 case 'p':
4128 flag_print_asm_name = 1;
4129 break;
4130 case 'P':
4131 flag_dump_rtl_in_asm = 1;
4132 flag_print_asm_name = 1;
4133 break;
4134 case 'v':
4135 graph_dump_format = vcg;
4136 break;
4137 case 'x':
4138 rtl_dump_and_exit = 1;
4139 break;
4140 case 'y':
4141 set_yydebug = 1;
4142 break;
4143 case 'D': /* These are handled by the preprocessor. */
4144 case 'I':
4145 break;
4146 case 'H':
4147 setup_core_dumping();
4148 break;
4149
4150 default:
4151 matched = 0;
4152 for (i = 0; i < (int) DFI_MAX; ++i)
4153 if (c == dump_file[i].debug_switch)
4154 {
4155 dump_file[i].enabled = 1;
4156 matched = 1;
4157 }
4158
4159 if (! matched)
4160 warning ("unrecognized gcc debugging option: %c", c);
4161 break;
4162 }
4163 }
4164
4165 /* Indexed by enum debug_info_type. */
4166 const char *const debug_type_names[] =
4167 {
4168 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff", "vms"
4169 };
4170
4171 /* Parse a -g... command line switch. ARG is the value after the -g.
4172 It is safe to access 'ARG - 2' to generate the full switch name.
4173 Return the number of strings consumed. */
4174
4175 void
4176 decode_g_option (const char *arg)
4177 {
4178 static unsigned level = 0;
4179 /* A lot of code assumes write_symbols == NO_DEBUG if the
4180 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
4181 of what debugging type has been selected). This records the
4182 selected type. It is an error to specify more than one
4183 debugging type. */
4184 static enum debug_info_type selected_debug_type = NO_DEBUG;
4185 /* Nonzero if debugging format has been explicitly set.
4186 -g and -ggdb don't explicitly set the debugging format so
4187 -gdwarf -g3 is equivalent to -gdwarf3. */
4188 static int type_explicitly_set_p = 0;
4189
4190 /* The maximum admissible debug level value. */
4191 static const unsigned max_debug_level = 3;
4192
4193 /* Look up ARG in the table. */
4194 for (da = debug_args; da->arg; da++)
4195 {
4196 const int da_len = strlen (da->arg);
4197
4198 if (da_len == 0 || ! strncmp (arg, da->arg, da_len))
4199 {
4200 enum debug_info_type type = da->debug_type;
4201 const char *p = arg + da_len;
4202
4203 if (*p && ! ISDIGIT (*p))
4204 continue;
4205
4206 /* A debug flag without a level defaults to level 2.
4207 Note we do not want to call read_integral_parameter
4208 for that case since it will call atoi which
4209 will return zero.
4210
4211 ??? We may want to generalize the interface to
4212 read_integral_parameter to better handle this case
4213 if this case shows up often. */
4214 if (*p)
4215 level = read_integral_parameter (p, 0, max_debug_level + 1);
4216 else
4217 level = (level == 0) ? 2 : level;
4218
4219 if (da_len > 1 && *p && !strncmp (arg, "dwarf", da_len))
4220 {
4221 error ("use -gdwarf -g%d for DWARF v1, level %d",
4222 level, level);
4223 if (level == 2)
4224 error ("use -gdwarf-2 for DWARF v2");
4225 }
4226
4227 if (level > max_debug_level)
4228 {
4229 warning ("\
4230 ignoring option `%s' due to invalid debug level specification",
4231 arg - 2);
4232 level = debug_info_level;
4233 }
4234
4235 if (type == NO_DEBUG)
4236 {
4237 type = PREFERRED_DEBUGGING_TYPE;
4238
4239 if (da_len > 1 && strncmp (arg, "gdb", da_len) == 0)
4240 {
4241 #ifdef DWARF2_DEBUGGING_INFO
4242 type = DWARF2_DEBUG;
4243 #else
4244 #ifdef DBX_DEBUGGING_INFO
4245 type = DBX_DEBUG;
4246 #endif
4247 #endif
4248 }
4249 }
4250
4251 if (type == NO_DEBUG)
4252 warning ("`%s': unknown or unsupported -g option", arg - 2);
4253
4254 /* Does it conflict with an already selected type? */
4255 if (type_explicitly_set_p
4256 /* -g/-ggdb don't conflict with anything. */
4257 && da->debug_type != NO_DEBUG
4258 && type != selected_debug_type)
4259 warning ("`%s' ignored, conflicts with `-g%s'",
4260 arg - 2, debug_type_names[(int) selected_debug_type]);
4261 else
4262 {
4263 /* If the format has already been set, -g/-ggdb
4264 only change the debug level. */
4265 if (type_explicitly_set_p && da->debug_type == NO_DEBUG)
4266 /* Don't change debugging type. */
4267 ;
4268 else
4269 {
4270 selected_debug_type = type;
4271 type_explicitly_set_p = da->debug_type != NO_DEBUG;
4272 }
4273
4274 write_symbols = (level == 0
4275 ? NO_DEBUG
4276 : selected_debug_type);
4277 use_gnu_debug_info_extensions = da->use_extensions_p;
4278 debug_info_level = (enum debug_info_level) level;
4279 }
4280
4281 break;
4282 }
4283 }
4284
4285 if (! da->arg)
4286 warning ("`-g%s': unknown or unsupported -g option", arg);
4287 }
4288
4289 /* Decode -m switches. */
4290 /* Decode the switch -mNAME. */
4291
4292 void
4293 set_target_switch (const char *name)
4294 {
4295 size_t j;
4296 int valid_target_option = 0;
4297
4298 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
4299 if (!strcmp (target_switches[j].name, name))
4300 {
4301 if (target_switches[j].value < 0)
4302 target_flags &= ~-target_switches[j].value;
4303 else
4304 target_flags |= target_switches[j].value;
4305 if (name[0] != 0)
4306 {
4307 if (target_switches[j].value < 0)
4308 target_flags_explicit |= -target_switches[j].value;
4309 else
4310 target_flags_explicit |= target_switches[j].value;
4311 }
4312 valid_target_option = 1;
4313 }
4314
4315 #ifdef TARGET_OPTIONS
4316 if (!valid_target_option)
4317 for (j = 0; j < ARRAY_SIZE (target_options); j++)
4318 {
4319 int len = strlen (target_options[j].prefix);
4320 if (target_options[j].value)
4321 {
4322 if (!strcmp (target_options[j].prefix, name))
4323 {
4324 *target_options[j].variable = target_options[j].value;
4325 valid_target_option = 1;
4326 }
4327 }
4328 else
4329 {
4330 if (!strncmp (target_options[j].prefix, name, len))
4331 {
4332 *target_options[j].variable = name + len;
4333 valid_target_option = 1;
4334 }
4335 }
4336 }
4337 #endif
4338
4339 if (!valid_target_option)
4340 error ("invalid option `%s'", name);
4341 }
4342
4343 /* Print version information to FILE.
4344 Each line begins with INDENT (for the case where FILE is the
4345 assembler output file). */
4346
4347 void
4348 print_version (FILE *file, const char *indent)
4349 {
4350 #ifndef __VERSION__
4351 #define __VERSION__ "[?]"
4352 #endif
4353 fnotice (file,
4354 #ifdef __GNUC__
4355 "%s%s%s version %s (%s)\n%s\tcompiled by GNU C version %s.\n"
4356 #else
4357 "%s%s%s version %s (%s) compiled by CC.\n"
4358 #endif
4359 , indent, *indent != 0 ? " " : "",
4360 lang_hooks.name, version_string, TARGET_NAME,
4361 indent, __VERSION__);
4362 fnotice (file, "%s%sGGC heuristics: --param ggc-min-expand=%d --param ggc-min-heapsize=%d\n",
4363 indent, *indent != 0 ? " " : "",
4364 PARAM_VALUE (GGC_MIN_EXPAND), PARAM_VALUE (GGC_MIN_HEAPSIZE));
4365 }
4366
4367 /* Print an option value and return the adjusted position in the line.
4368 ??? We don't handle error returns from fprintf (disk full); presumably
4369 other code will catch a disk full though. */
4370
4371 static int
4372 print_single_switch (FILE *file, int pos, int max,
4373 const char *indent, const char *sep, const char *term,
4374 const char *type, const char *name)
4375 {
4376 /* The ultrix fprintf returns 0 on success, so compute the result we want
4377 here since we need it for the following test. */
4378 int len = strlen (sep) + strlen (type) + strlen (name);
4379
4380 if (pos != 0
4381 && pos + len > max)
4382 {
4383 fprintf (file, "%s", term);
4384 pos = 0;
4385 }
4386 if (pos == 0)
4387 {
4388 fprintf (file, "%s", indent);
4389 pos = strlen (indent);
4390 }
4391 fprintf (file, "%s%s%s", sep, type, name);
4392 pos += len;
4393 return pos;
4394 }
4395
4396 /* Print active target switches to FILE.
4397 POS is the current cursor position and MAX is the size of a "line".
4398 Each line begins with INDENT and ends with TERM.
4399 Each switch is separated from the next by SEP. */
4400
4401 static void
4402 print_switch_values (FILE *file, int pos, int max,
4403 const char *indent, const char *sep, const char *term)
4404 {
4405 size_t j;
4406 const char **p;
4407
4408 /* Fill in the -frandom-seed option, if the user didn't pass it, so
4409 that it can be printed below. This helps reproducibility. */
4410 randomize ();
4411
4412 /* Print the options as passed. */
4413 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
4414 _("options passed: "), "");
4415
4416 for (p = &save_argv[1]; *p != NULL; p++)
4417 if (**p == '-')
4418 {
4419 /* Ignore these. */
4420 if (strcmp (*p, "-o") == 0)
4421 {
4422 if (p[1] != NULL)
4423 p++;
4424 continue;
4425 }
4426 if (strcmp (*p, "-quiet") == 0)
4427 continue;
4428 if (strcmp (*p, "-version") == 0)
4429 continue;
4430 if ((*p)[1] == 'd')
4431 continue;
4432
4433 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
4434 }
4435 if (pos > 0)
4436 fprintf (file, "%s", term);
4437
4438 /* Print the -f and -m options that have been enabled.
4439 We don't handle language specific options but printing argv
4440 should suffice. */
4441
4442 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
4443 _("options enabled: "), "");
4444
4445 for (j = 0; j < ARRAY_SIZE (f_options); j++)
4446 if (*f_options[j].variable == f_options[j].on_value)
4447 pos = print_single_switch (file, pos, max, indent, sep, term,
4448 "-f", f_options[j].string);
4449
4450 /* Print target specific options. */
4451
4452 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
4453 if (target_switches[j].name[0] != '\0'
4454 && target_switches[j].value > 0
4455 && ((target_switches[j].value & target_flags)
4456 == target_switches[j].value))
4457 {
4458 pos = print_single_switch (file, pos, max, indent, sep, term,
4459 "-m", target_switches[j].name);
4460 }
4461
4462 #ifdef TARGET_OPTIONS
4463 for (j = 0; j < ARRAY_SIZE (target_options); j++)
4464 if (*target_options[j].variable != NULL)
4465 {
4466 char prefix[256];
4467 sprintf (prefix, "-m%s", target_options[j].prefix);
4468 pos = print_single_switch (file, pos, max, indent, sep, term,
4469 prefix, *target_options[j].variable);
4470 }
4471 #endif
4472
4473 fprintf (file, "%s", term);
4474 }
4475
4476 /* Open assembly code output file. Do this even if -fsyntax-only is
4477 on, because then the driver will have provided the name of a
4478 temporary file or bit bucket for us. NAME is the file specified on
4479 the command line, possibly NULL. */
4480 static void
4481 init_asm_output (const char *name)
4482 {
4483 if (name == NULL && asm_file_name == 0)
4484 asm_out_file = stdout;
4485 else
4486 {
4487 if (asm_file_name == 0)
4488 {
4489 int len = strlen (dump_base_name);
4490 char *dumpname = (char *) xmalloc (len + 6);
4491 memcpy (dumpname, dump_base_name, len + 1);
4492 strip_off_ending (dumpname, len);
4493 strcat (dumpname, ".s");
4494 asm_file_name = dumpname;
4495 }
4496 if (!strcmp (asm_file_name, "-"))
4497 asm_out_file = stdout;
4498 else
4499 asm_out_file = fopen (asm_file_name, "w+");
4500 if (asm_out_file == 0)
4501 fatal_error ("can't open %s for writing: %m", asm_file_name);
4502 }
4503
4504 #ifdef IO_BUFFER_SIZE
4505 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
4506 _IOFBF, IO_BUFFER_SIZE);
4507 #endif
4508
4509 if (!flag_syntax_only)
4510 {
4511 targetm.asm_out.file_start ();
4512
4513 #ifdef ASM_COMMENT_START
4514 if (flag_verbose_asm)
4515 {
4516 /* Print the list of options in effect. */
4517 print_version (asm_out_file, ASM_COMMENT_START);
4518 print_switch_values (asm_out_file, 0, MAX_LINE,
4519 ASM_COMMENT_START, " ", "\n");
4520 /* Add a blank line here so it appears in assembler output but not
4521 screen output. */
4522 fprintf (asm_out_file, "\n");
4523 }
4524 #endif
4525 }
4526 }
4527
4528 /* Initialization of the front end environment, before command line
4529 options are parsed. Signal handlers, internationalization etc.
4530 ARGV0 is main's argv[0]. */
4531 static void
4532 general_init (const char *argv0)
4533 {
4534 const char *p;
4535
4536 p = argv0 + strlen (argv0);
4537 while (p != argv0 && !IS_DIR_SEPARATOR (p[-1]))
4538 --p;
4539 progname = p;
4540
4541 xmalloc_set_program_name (progname);
4542
4543 hex_init ();
4544
4545 gcc_init_libintl ();
4546
4547 /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages. */
4548 #ifdef SIGSEGV
4549 signal (SIGSEGV, crash_signal);
4550 #endif
4551 #ifdef SIGILL
4552 signal (SIGILL, crash_signal);
4553 #endif
4554 #ifdef SIGBUS
4555 signal (SIGBUS, crash_signal);
4556 #endif
4557 #ifdef SIGABRT
4558 signal (SIGABRT, crash_signal);
4559 #endif
4560 #if defined SIGIOT && (!defined SIGABRT || SIGABRT != SIGIOT)
4561 signal (SIGIOT, crash_signal);
4562 #endif
4563 #ifdef SIGFPE
4564 signal (SIGFPE, crash_signal);
4565 #endif
4566
4567 /* Other host-specific signal setup. */
4568 (*host_hooks.extra_signals)();
4569
4570 /* Initialize the diagnostics reporting machinery, so option parsing
4571 can give warnings and errors. */
4572 diagnostic_initialize (global_dc);
4573
4574 /* Initialize the garbage-collector, string pools and tree type hash
4575 table. */
4576 init_ggc ();
4577 init_stringpool ();
4578 init_ttree ();
4579
4580 /* Initialize register usage now so switches may override. */
4581 init_reg_sets ();
4582
4583 /* Register the language-independent parameters. */
4584 add_params (lang_independent_params, LAST_PARAM);
4585
4586 /* This must be done after add_params but before argument processing. */
4587 init_ggc_heuristics();
4588 }
4589
4590 /* Process the options that have been parsed. */
4591 static void
4592 process_options (void)
4593 {
4594 /* Allow the front end to perform consistency checks and do further
4595 initialization based on the command line options. This hook also
4596 sets the original filename if appropriate (e.g. foo.i -> foo.c)
4597 so we can correctly initialize debug output. */
4598 no_backend = (*lang_hooks.post_options) (&main_input_filename);
4599 input_filename = main_input_filename;
4600
4601 #ifdef OVERRIDE_OPTIONS
4602 /* Some machines may reject certain combinations of options. */
4603 OVERRIDE_OPTIONS;
4604 #endif
4605
4606 /* Set aux_base_name if not already set. */
4607 if (aux_base_name)
4608 ;
4609 else if (main_input_filename)
4610 {
4611 char *name = xstrdup (lbasename (main_input_filename));
4612
4613 strip_off_ending (name, strlen (name));
4614 aux_base_name = name;
4615 }
4616 else
4617 aux_base_name = "gccaux";
4618
4619 /* Set up the align_*_log variables, defaulting them to 1 if they
4620 were still unset. */
4621 if (align_loops <= 0) align_loops = 1;
4622 if (align_loops_max_skip > align_loops || !align_loops)
4623 align_loops_max_skip = align_loops - 1;
4624 align_loops_log = floor_log2 (align_loops * 2 - 1);
4625 if (align_jumps <= 0) align_jumps = 1;
4626 if (align_jumps_max_skip > align_jumps || !align_jumps)
4627 align_jumps_max_skip = align_jumps - 1;
4628 align_jumps_log = floor_log2 (align_jumps * 2 - 1);
4629 if (align_labels <= 0) align_labels = 1;
4630 align_labels_log = floor_log2 (align_labels * 2 - 1);
4631 if (align_labels_max_skip > align_labels || !align_labels)
4632 align_labels_max_skip = align_labels - 1;
4633 if (align_functions <= 0) align_functions = 1;
4634 align_functions_log = floor_log2 (align_functions * 2 - 1);
4635
4636 /* Unrolling all loops implies that standard loop unrolling must also
4637 be done. */
4638 if (flag_unroll_all_loops)
4639 flag_unroll_loops = 1;
4640
4641 if (flag_unroll_loops)
4642 {
4643 flag_old_unroll_loops = 0;
4644 flag_old_unroll_all_loops = 0;
4645 }
4646
4647 if (flag_old_unroll_all_loops)
4648 flag_old_unroll_loops = 1;
4649
4650 /* Old loop unrolling requires that strength_reduction be on also. Silently
4651 turn on strength reduction here if it isn't already on. Also, the loop
4652 unrolling code assumes that cse will be run after loop, so that must
4653 be turned on also. */
4654 if (flag_old_unroll_loops)
4655 {
4656 flag_strength_reduce = 1;
4657 flag_rerun_cse_after_loop = 1;
4658 }
4659 if (flag_unroll_loops || flag_peel_loops)
4660 flag_rerun_cse_after_loop = 1;
4661
4662 if (flag_non_call_exceptions)
4663 flag_asynchronous_unwind_tables = 1;
4664 if (flag_asynchronous_unwind_tables)
4665 flag_unwind_tables = 1;
4666
4667 /* Disable unit-at-a-time mode for frontends not supporting callgraph
4668 interface. */
4669 if (flag_unit_at_a_time && ! lang_hooks.callgraph.expand_function)
4670 flag_unit_at_a_time = 0;
4671
4672 /* Warn about options that are not supported on this machine. */
4673 #ifndef INSN_SCHEDULING
4674 if (flag_schedule_insns || flag_schedule_insns_after_reload)
4675 warning ("instruction scheduling not supported on this target machine");
4676 #endif
4677 #ifndef DELAY_SLOTS
4678 if (flag_delayed_branch)
4679 warning ("this target machine does not have delayed branches");
4680 #endif
4681
4682 user_label_prefix = USER_LABEL_PREFIX;
4683 if (flag_leading_underscore != -1)
4684 {
4685 /* If the default prefix is more complicated than "" or "_",
4686 issue a warning and ignore this option. */
4687 if (user_label_prefix[0] == 0 ||
4688 (user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
4689 {
4690 user_label_prefix = flag_leading_underscore ? "_" : "";
4691 }
4692 else
4693 warning ("-f%sleading-underscore not supported on this target machine",
4694 flag_leading_underscore ? "" : "no-");
4695 }
4696
4697 /* If we are in verbose mode, write out the version and maybe all the
4698 option flags in use. */
4699 if (version_flag)
4700 {
4701 print_version (stderr, "");
4702 if (! quiet_flag)
4703 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
4704 }
4705
4706 if (flag_syntax_only)
4707 {
4708 write_symbols = NO_DEBUG;
4709 profile_flag = 0;
4710 }
4711
4712 /* Now we know write_symbols, set up the debug hooks based on it.
4713 By default we do nothing for debug output. */
4714 #if defined(DBX_DEBUGGING_INFO)
4715 if (write_symbols == DBX_DEBUG)
4716 debug_hooks = &dbx_debug_hooks;
4717 #endif
4718 #if defined(XCOFF_DEBUGGING_INFO)
4719 if (write_symbols == XCOFF_DEBUG)
4720 debug_hooks = &xcoff_debug_hooks;
4721 #endif
4722 #ifdef SDB_DEBUGGING_INFO
4723 if (write_symbols == SDB_DEBUG)
4724 debug_hooks = &sdb_debug_hooks;
4725 #endif
4726 #ifdef DWARF_DEBUGGING_INFO
4727 if (write_symbols == DWARF_DEBUG)
4728 debug_hooks = &dwarf_debug_hooks;
4729 #endif
4730 #ifdef DWARF2_DEBUGGING_INFO
4731 if (write_symbols == DWARF2_DEBUG)
4732 debug_hooks = &dwarf2_debug_hooks;
4733 #endif
4734 #ifdef VMS_DEBUGGING_INFO
4735 if (write_symbols == VMS_DEBUG || write_symbols == VMS_AND_DWARF2_DEBUG)
4736 debug_hooks = &vmsdbg_debug_hooks;
4737 #endif
4738
4739 /* If auxiliary info generation is desired, open the output file.
4740 This goes in the same directory as the source file--unlike
4741 all the other output files. */
4742 if (flag_gen_aux_info)
4743 {
4744 aux_info_file = fopen (aux_info_file_name, "w");
4745 if (aux_info_file == 0)
4746 fatal_error ("can't open %s: %m", aux_info_file_name);
4747 }
4748
4749 if (! targetm.have_named_sections)
4750 {
4751 if (flag_function_sections)
4752 {
4753 warning ("-ffunction-sections not supported for this target");
4754 flag_function_sections = 0;
4755 }
4756 if (flag_data_sections)
4757 {
4758 warning ("-fdata-sections not supported for this target");
4759 flag_data_sections = 0;
4760 }
4761 }
4762
4763 if (flag_function_sections && profile_flag)
4764 {
4765 warning ("-ffunction-sections disabled; it makes profiling impossible");
4766 flag_function_sections = 0;
4767 }
4768
4769 #ifndef HAVE_prefetch
4770 if (flag_prefetch_loop_arrays)
4771 {
4772 warning ("-fprefetch-loop-arrays not supported for this target");
4773 flag_prefetch_loop_arrays = 0;
4774 }
4775 #else
4776 if (flag_prefetch_loop_arrays && !HAVE_prefetch)
4777 {
4778 warning ("-fprefetch-loop-arrays not supported for this target (try -march switches)");
4779 flag_prefetch_loop_arrays = 0;
4780 }
4781 #endif
4782
4783 /* This combination of options isn't handled for i386 targets and doesn't
4784 make much sense anyway, so don't allow it. */
4785 if (flag_prefetch_loop_arrays && optimize_size)
4786 {
4787 warning ("-fprefetch-loop-arrays is not supported with -Os");
4788 flag_prefetch_loop_arrays = 0;
4789 }
4790
4791 #ifndef OBJECT_FORMAT_ELF
4792 if (flag_function_sections && write_symbols != NO_DEBUG)
4793 warning ("-ffunction-sections may affect debugging on some targets");
4794 #endif
4795
4796 /* The presence of IEEE signaling NaNs, implies all math can trap. */
4797 if (flag_signaling_nans)
4798 flag_trapping_math = 1;
4799 }
4800
4801 /* Initialize the compiler back end. */
4802 static void
4803 backend_init (void)
4804 {
4805 /* init_emit_once uses reg_raw_mode and therefore must be called
4806 after init_regs which initialized reg_raw_mode. */
4807 init_regs ();
4808 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
4809 || debug_info_level == DINFO_LEVEL_VERBOSE
4810 #ifdef VMS_DEBUGGING_INFO
4811 /* Enable line number info for traceback. */
4812 || debug_info_level > DINFO_LEVEL_NONE
4813 #endif
4814 || flag_test_coverage
4815 || warn_notreached);
4816 init_fake_stack_mems ();
4817 init_alias_once ();
4818 init_loop ();
4819 init_reload ();
4820 init_function_once ();
4821 init_varasm_once ();
4822
4823 /* The following initialization functions need to generate rtl, so
4824 provide a dummy function context for them. */
4825 init_dummy_function_start ();
4826 init_expmed ();
4827 if (flag_caller_saves)
4828 init_caller_save ();
4829 expand_dummy_function_end ();
4830 }
4831
4832 /* Language-dependent initialization. Returns nonzero on success. */
4833 static int
4834 lang_dependent_init (const char *name)
4835 {
4836 if (dump_base_name == 0)
4837 dump_base_name = name ? name : "gccdump";
4838
4839 /* Other front-end initialization. */
4840 if ((*lang_hooks.init) () == 0)
4841 return 0;
4842
4843 init_asm_output (name);
4844
4845 /* These create various _DECL nodes, so need to be called after the
4846 front end is initialized. */
4847 init_eh ();
4848 init_optabs ();
4849
4850 /* The following initialization functions need to generate rtl, so
4851 provide a dummy function context for them. */
4852 init_dummy_function_start ();
4853 init_expr_once ();
4854 expand_dummy_function_end ();
4855
4856 /* If dbx symbol table desired, initialize writing it and output the
4857 predefined types. */
4858 timevar_push (TV_SYMOUT);
4859
4860 #ifdef DWARF2_UNWIND_INFO
4861 if (dwarf2out_do_frame ())
4862 dwarf2out_frame_init ();
4863 #endif
4864
4865 /* Now we have the correct original filename, we can initialize
4866 debug output. */
4867 (*debug_hooks->init) (name);
4868
4869 timevar_pop (TV_SYMOUT);
4870
4871 return 1;
4872 }
4873
4874 /* Clean up: close opened files, etc. */
4875
4876 static void
4877 finalize (void)
4878 {
4879 /* Close the dump files. */
4880 if (flag_gen_aux_info)
4881 {
4882 fclose (aux_info_file);
4883 if (errorcount)
4884 unlink (aux_info_file_name);
4885 }
4886
4887 /* Close non-debugging input and output files. Take special care to note
4888 whether fclose returns an error, since the pages might still be on the
4889 buffer chain while the file is open. */
4890
4891 if (asm_out_file)
4892 {
4893 if (ferror (asm_out_file) != 0)
4894 fatal_error ("error writing to %s: %m", asm_file_name);
4895 if (fclose (asm_out_file) != 0)
4896 fatal_error ("error closing %s: %m", asm_file_name);
4897 }
4898
4899 /* Do whatever is necessary to finish printing the graphs. */
4900 if (graph_dump_format != no_graph)
4901 {
4902 int i;
4903
4904 for (i = 0; i < (int) DFI_MAX; ++i)
4905 if (dump_file[i].initialized && dump_file[i].graph_dump_p)
4906 {
4907 char seq[16];
4908 char *suffix;
4909
4910 sprintf (seq, DUMPFILE_FORMAT, i);
4911 suffix = concat (seq, dump_file[i].extension, NULL);
4912 finish_graph_dump_file (dump_base_name, suffix);
4913 free (suffix);
4914 }
4915 }
4916
4917 if (mem_report)
4918 {
4919 ggc_print_statistics ();
4920 stringpool_statistics ();
4921 dump_tree_statistics ();
4922 }
4923
4924 /* Free up memory for the benefit of leak detectors. */
4925 free_reg_info ();
4926
4927 /* Language-specific end of compilation actions. */
4928 (*lang_hooks.finish) ();
4929 }
4930
4931 /* Initialize the compiler, and compile the input file. */
4932 static void
4933 do_compile (void)
4934 {
4935 /* Initialize timing first. The C front ends read the main file in
4936 the post_options hook, and C++ does file timings. */
4937 if (time_report || !quiet_flag || flag_detailed_statistics)
4938 timevar_init ();
4939 timevar_start (TV_TOTAL);
4940
4941 process_options ();
4942
4943 /* Don't do any more if an error has already occurred. */
4944 if (!errorcount)
4945 {
4946 /* Set up the back-end if requested. */
4947 if (!no_backend)
4948 backend_init ();
4949
4950 if (flag_unit_at_a_time)
4951 {
4952 open_dump_file (DFI_cgraph, NULL);
4953 cgraph_dump_file = rtl_dump_file;
4954 rtl_dump_file = NULL;
4955 }
4956 /* Language-dependent initialization. Returns true on success. */
4957 if (lang_dependent_init (main_input_filename))
4958 compile_file ();
4959
4960 if (flag_unit_at_a_time)
4961 {
4962 rtl_dump_file = cgraph_dump_file;
4963 cgraph_dump_file = NULL;
4964 close_dump_file (DFI_cgraph, NULL, NULL_RTX);
4965 }
4966
4967 finalize ();
4968 }
4969
4970 /* Stop timing and print the times. */
4971 timevar_stop (TV_TOTAL);
4972 timevar_print (stderr);
4973 }
4974
4975 /* Entry point of cc1, cc1plus, jc1, f771, etc.
4976 Decode command args, then call compile_file.
4977 Exit code is FATAL_EXIT_CODE if can't open files or if there were
4978 any errors, or SUCCESS_EXIT_CODE if compilation succeeded.
4979
4980 It is not safe to call this function more than once. */
4981
4982 int
4983 toplev_main (unsigned int argc, const char **argv)
4984 {
4985 save_argv = argv;
4986
4987 /* Initialization of GCC's environment, and diagnostics. */
4988 general_init (argv[0]);
4989
4990 /* Parse the options and do minimal processing; basically just
4991 enough to default flags appropriately. */
4992 decode_options (argc, argv);
4993
4994 randomize ();
4995
4996 /* Exit early if we can (e.g. -help). */
4997 if (!exit_after_options)
4998 do_compile ();
4999
5000 if (errorcount || sorrycount)
5001 return (FATAL_EXIT_CODE);
5002
5003 return (SUCCESS_EXIT_CODE);
5004 }