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.
5 This file is part of GCC.
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
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
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
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. */
28 #undef FLOAT /* This is for hpux. They should change hpux. */
29 #undef FFS /* Some systems define this in param.h. */
31 #include "coretypes.h"
35 #ifdef HAVE_SYS_RESOURCE_H
36 # include <sys/resource.h>
39 #ifdef HAVE_SYS_TIMES_H
40 # include <sys/times.h>
48 #include "insn-attr.h"
49 #include "insn-config.h"
50 #include "insn-flags.h"
51 #include "hard-reg-set.h"
58 #include "basic-block.h"
65 #include "diagnostic.h"
69 #include "dwarf2asm.h"
70 #include "integrate.h"
74 #include "langhooks.h"
75 #include "cfglayout.h"
77 #include "hosthooks.h"
82 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
83 #include "dwarf2out.h"
86 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
90 #ifdef SDB_DEBUGGING_INFO
94 #ifdef XCOFF_DEBUGGING_INFO
95 #include "xcoffout.h" /* Needed for external data
96 declarations for e.g. AIX 4.x. */
99 /* Carry information from ASM_DECLARE_OBJECT_NAME
100 to ASM_FINISH_DECLARE_OBJECT. */
102 extern int size_directive_output;
103 extern tree last_assemble_variable_decl;
105 extern void reg_alloc (void);
107 static void general_init (char *);
108 static void parse_options_and_default_flags (int, char **);
109 static void do_compile (void);
110 static void process_options (void);
111 static void backend_init (void);
112 static int lang_dependent_init (const char *);
113 static void init_asm_output (const char *);
114 static void finalize (void);
116 static void crash_signal (int) ATTRIBUTE_NORETURN;
117 static void setup_core_dumping (void);
118 static void compile_file (void);
120 static int print_single_switch (FILE *, int, int, const char *,
121 const char *, const char *,
122 const char *, const char *);
123 static void print_switch_values (FILE *, int, int, const char *,
124 const char *, const char *);
126 /* Rest of compilation helper functions. */
127 static bool rest_of_handle_inlining (tree);
128 static rtx rest_of_handle_ssa (tree, rtx);
129 static void rest_of_handle_cse (tree, rtx);
130 static void rest_of_handle_cse2 (tree, rtx);
131 static void rest_of_handle_gcse (tree, rtx);
132 static void rest_of_handle_life (tree, rtx);
133 static void rest_of_handle_loop_optimize (tree, rtx);
134 static void rest_of_handle_loop2 (tree, rtx);
135 static void rest_of_handle_jump_bypass (tree, rtx);
136 static void rest_of_handle_sibling_calls (rtx);
137 static void rest_of_handle_null_pointer (tree, rtx);
138 static void rest_of_handle_addresof (tree, rtx);
139 static void rest_of_handle_cfg (tree, rtx);
140 static void rest_of_handle_branch_prob (tree, rtx);
141 static void rest_of_handle_if_conversion (tree, rtx);
142 static void rest_of_handle_if_after_combine (tree, rtx);
143 static void rest_of_handle_tracer (tree, rtx);
144 static void rest_of_handle_combine (tree, rtx);
145 static void rest_of_handle_regmove (tree, rtx);
146 #ifdef INSN_SCHEDULING
147 static void rest_of_handle_sched (tree, rtx);
148 static void rest_of_handle_sched2 (tree, rtx);
150 static bool rest_of_handle_new_regalloc (tree, rtx, int *);
151 static bool rest_of_handle_old_regalloc (tree, rtx, int *);
152 static void rest_of_handle_regrename (tree, rtx);
153 static void rest_of_handle_reorder_blocks (tree, rtx);
155 static void rest_of_handle_stack_regs (tree, rtx);
157 static void rest_of_handle_machine_reorg (tree, rtx);
159 static void rest_of_handle_delay_slots (tree, rtx);
161 static void rest_of_handle_final (tree, rtx);
163 /* Nonzero to dump debug info whilst parsing (-dy option). */
164 static int set_yydebug;
166 /* True if we don't need a backend (e.g. preprocessing only). */
167 static bool no_backend;
169 /* Length of line when printing switch values. */
172 /* Name of program invoked, sans directories. */
174 const char *progname;
176 /* Copy of arguments to toplev_main. */
180 /* Name of top-level original source file (what was input to cpp).
181 This comes from the #-command at the beginning of the actual input.
182 If there isn't any there, then this is the cc1 input file name. */
184 const char *main_input_filename;
186 /* Current position in real source file. */
188 location_t input_location;
190 /* Nonzero if it is unsafe to create any new pseudo registers. */
193 /* Stack of currently pending input files. */
195 struct file_stack *input_file_stack;
197 /* Incremented on each change to input_file_stack. */
198 int input_file_stack_tick;
200 /* Name to use as base of names for dump output files. */
202 const char *dump_base_name;
204 /* Name to use as a base for auxiliary output files. */
206 const char *aux_base_name;
208 /* Format to use to print dumpfile index value */
209 #ifndef DUMPFILE_FORMAT
210 #define DUMPFILE_FORMAT ".%02d."
213 /* Bit flags that specify the machine subtype we are compiling for.
214 Bits are tested using macros TARGET_... defined in the tm.h file
215 and set by `-m...' switches. Must be defined in rtlanal.c. */
217 extern int target_flags;
219 /* A mask of target_flags that includes bit X if X was set or cleared
220 on the command line. */
222 int target_flags_explicit;
224 /* Debug hooks - dependent upon command line options. */
226 const struct gcc_debug_hooks *debug_hooks = &do_nothing_debug_hooks;
228 /* Describes a dump file. */
230 struct dump_file_info
232 /* The unique extension to apply, e.g. ".jump". */
233 const char *const extension;
235 /* The -d<c> character that enables this dump file. */
236 char const debug_switch;
238 /* True if there is a corresponding graph dump file. */
239 char const graph_dump_p;
241 /* True if the user selected this dump. */
244 /* True if the files have been initialized (ie truncated). */
248 /* Enumerate the extant dump files. */
285 DFI_branch_target_load,
293 /* Describes all the dump files. Should be kept in order of the
294 pass and in sync with dump_file_index above.
296 Remaining -d letters:
302 static struct dump_file_info dump_file[DFI_MAX] =
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 },
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);
348 /* Other flags saying which kinds of debugging dump have been requested. */
350 int rtl_dump_and_exit;
351 int flag_print_asm_name;
352 enum graph_dump_types graph_dump_format;
354 /* Name for output file of assembly code, specified with -o. */
356 const char *asm_file_name;
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;
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;
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;
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. */
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. */
387 int optimize_size = 0;
389 /* The FUNCTION_DECL for the function currently being compiled,
390 or 0 if between functions. */
391 tree current_function_decl;
393 /* Set to the FUNC_BEGIN label of the current function, or NULL_TREE
395 tree current_function_func_begin_label;
397 /* Nonzero if doing dwarf2 duplicate elimination. */
399 int flag_eliminate_dwarf2_dups = 0;
401 /* Nonzero if doing unused type elimination. */
403 int flag_eliminate_unused_debug_types = 1;
405 /* Nonzero if generating code to do profiling. */
407 int profile_flag = 0;
409 /* Nonzero if generating code to profile program flow graph arcs. */
411 int profile_arc_flag = 0;
413 /* Nonzero if generating info for gcov to calculate line test coverage. */
415 int flag_test_coverage = 0;
417 /* Nonzero indicates that branch taken probabilities should be calculated. */
419 int flag_branch_probabilities = 0;
421 /* Nonzero if basic blocks should be reordered. */
423 int flag_reorder_blocks = 0;
425 /* Nonzero if functions should be reordered. */
427 int flag_reorder_functions = 0;
429 /* Nonzero if registers should be renamed. */
431 int flag_rename_registers = 0;
432 int flag_cprop_registers = 0;
434 /* Nonzero for -pedantic switch: warn about anything
435 that standard spec forbids. */
439 /* Temporarily suppress certain warnings.
440 This is set while reading code from a system header file. */
442 int in_system_header = 0;
444 /* Don't print functions as they are compiled. -quiet. */
448 /* Print times taken by the various passes. -ftime-report. */
452 /* Print memory still in use at end of compilation (which may have little
453 to do with peak memory consumption). -fmem-report. */
457 /* Nonzero means to collect statistics which might be expensive
458 and to print them when we are done. */
459 int flag_detailed_statistics = 0;
463 /* Nonzero means `char' should be signed. */
465 int flag_signed_char;
467 /* Nonzero means give an enum type only as many bytes as it needs. */
469 int flag_short_enums;
471 /* Nonzero for -fcaller-saves: allocate values in regs that need to
472 be saved across function calls, if that produces overall better code.
473 Optional now, so people can test it. */
475 #ifdef DEFAULT_CALLER_SAVES
476 int flag_caller_saves = 1;
478 int flag_caller_saves = 0;
481 /* Nonzero if structures and unions should be returned in memory.
483 This should only be defined if compatibility with another compiler or
484 with an ABI is needed, because it results in slower code. */
486 #ifndef DEFAULT_PCC_STRUCT_RETURN
487 #define DEFAULT_PCC_STRUCT_RETURN 1
490 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
492 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
494 /* Nonzero for -fforce-mem: load memory value into a register
495 before arithmetic on it. This makes better cse but slower compilation. */
497 int flag_force_mem = 0;
499 /* Nonzero for -fforce-addr: load memory address into a register before
500 reference to memory. This makes better cse but slower compilation. */
502 int flag_force_addr = 0;
504 /* Nonzero for -fdefer-pop: don't pop args after each function call;
505 instead save them up to pop many calls' args with one insns. */
507 int flag_defer_pop = 0;
509 /* Nonzero for -ffloat-store: don't allocate floats and doubles
510 in extended-precision registers. */
512 int flag_float_store = 0;
514 /* Nonzero for -fcse-follow-jumps:
515 have cse follow jumps to do a more extensive job. */
517 int flag_cse_follow_jumps;
519 /* Nonzero for -fcse-skip-blocks:
520 have cse follow a branch around a block. */
521 int flag_cse_skip_blocks;
523 /* Nonzero for -fexpensive-optimizations:
524 perform miscellaneous relatively-expensive optimizations. */
525 int flag_expensive_optimizations;
527 /* Nonzero for -fthread-jumps:
528 have jump optimize output of loop. */
530 int flag_thread_jumps;
532 /* Nonzero enables strength-reduction in loop.c. */
534 int flag_strength_reduce = 0;
536 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
537 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
538 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
541 int flag_old_unroll_loops;
543 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
544 This is generally not a win. */
546 int flag_old_unroll_all_loops;
548 /* Enables unrolling of simple loops in loop-unroll.c. */
549 int flag_unroll_loops;
551 /* Enables unrolling of all loops in loop-unroll.c. */
552 int flag_unroll_all_loops;
554 /* Nonzero enables loop peeling. */
557 /* Nonzero enables loop unswitching. */
558 int flag_unswitch_loops;
560 /* Nonzero enables prefetch optimizations for arrays in loops. */
562 int flag_prefetch_loop_arrays;
564 /* Nonzero forces all invariant computations in loops to be moved
567 int flag_move_all_movables = 0;
569 /* Nonzero forces all general induction variables in loops to be
572 int flag_reduce_all_givs = 0;
574 /* Nonzero to perform full register move optimization passes. This is the
577 int flag_regmove = 0;
579 /* Nonzero for -fwritable-strings:
580 store string constants in data segment and don't uniquize them. */
582 int flag_writable_strings = 0;
584 /* Nonzero means don't put addresses of constant functions in registers.
585 Used for compiling the Unix kernel, where strange substitutions are
586 done on the assembly output. */
588 int flag_no_function_cse = 0;
590 /* Nonzero for -fomit-frame-pointer:
591 don't make a frame pointer in simple functions that don't require one. */
593 int flag_omit_frame_pointer = 0;
595 /* Nonzero means place each function into its own section on those platforms
596 which support arbitrary section names and unlimited numbers of sections. */
598 int flag_function_sections = 0;
600 /* ... and similar for data. */
602 int flag_data_sections = 0;
604 /* Nonzero to inhibit use of define_optimization peephole opts. */
606 int flag_no_peephole = 0;
608 /* Nonzero allows GCC to optimize sibling and tail recursive calls. */
610 int flag_optimize_sibling_calls = 0;
612 /* Nonzero means the front end generally wants `errno' maintained by math
613 operations, like built-in SQRT. */
615 int flag_errno_math = 1;
617 /* Nonzero means that unsafe floating-point math optimizations are allowed
618 for the sake of speed. IEEE compliance is not guaranteed, and operations
619 are allowed to assume that their arguments and results are "normal"
620 (e.g., nonnegative for SQRT). */
622 int flag_unsafe_math_optimizations = 0;
624 /* Nonzero means that no NaNs or +-Infs are expected. */
626 int flag_finite_math_only = 0;
628 /* Zero means that floating-point math operations cannot generate a
629 (user-visible) trap. This is the case, for example, in nonstop
630 IEEE 754 arithmetic. Trapping conditions include division by zero,
631 overflow, underflow, invalid and inexact, but does not include
632 operations on signaling NaNs (see below). */
634 int flag_trapping_math = 1;
636 /* Nonzero means disable transformations observable by signaling NaNs.
637 This option implies that any operation on an IEEE signaling NaN can
638 generate a (user-visible) trap. */
640 int flag_signaling_nans = 0;
642 /* 0 means straightforward implementation of complex divide acceptable.
643 1 means wide ranges of inputs must work for complex divide.
644 2 means C99-like requirements for complex divide (not yet implemented). */
646 int flag_complex_divide_method = 0;
648 /* Nonzero means just do syntax checking; don't output anything. */
650 int flag_syntax_only = 0;
652 /* Nonzero means perform loop optimizer. */
654 int flag_loop_optimize;
656 /* Nonzero means perform crossjumping. */
658 int flag_crossjumping;
660 /* Nonzero means perform if conversion. */
662 int flag_if_conversion;
664 /* Nonzero means perform if conversion after reload. */
666 int flag_if_conversion2;
668 /* Nonzero means to use global dataflow analysis to eliminate
669 useless null pointer tests. */
671 int flag_delete_null_pointer_checks;
673 /* Nonzero means perform global CSE. */
677 /* Nonzero means to do the enhanced load motion during gcse, which trys
678 to hoist loads by not killing them when a store to the same location
681 int flag_gcse_lm = 1;
683 /* Nonzero means to perform store motion after gcse, which will try to
684 move stores closer to the exit block. Its not very effective without
687 int flag_gcse_sm = 1;
689 /* Perform target register optimization before prologue / epilogue
692 int flag_branch_target_load_optimize = 0;
694 /* Perform target register optimization after prologue / epilogue
695 threading and jump2. */
697 int flag_branch_target_load_optimize2 = 0;
699 /* Nonzero means to rerun cse after loop optimization. This increases
700 compilation time about 20% and picks up a few more common expressions. */
702 int flag_rerun_cse_after_loop;
704 /* Nonzero means to run loop optimizations twice. */
706 int flag_rerun_loop_opt;
708 /* Nonzero for -finline-functions: ok to inline functions that look like
709 good inline candidates. */
711 int flag_inline_functions;
713 /* Nonzero for -fkeep-inline-functions: even if we make a function
714 go inline everywhere, keep its definition around for debugging
717 int flag_keep_inline_functions;
719 /* Nonzero means that functions will not be inlined. */
721 int flag_no_inline = 2;
723 /* Nonzero means that we don't want inlining by virtue of -fno-inline,
724 not just because the tree inliner turned us off. */
726 int flag_really_no_inline = 2;
728 /* Nonzero means that we should emit static const variables
729 regardless of whether or not optimization is turned on. */
731 int flag_keep_static_consts = 1;
733 /* Nonzero means we should be saving declaration info into a .X file. */
735 int flag_gen_aux_info = 0;
737 /* Specified name of aux-info file. */
739 const char *aux_info_file_name;
741 /* Nonzero means make the text shared if supported. */
743 int flag_shared_data;
745 /* Nonzero means schedule into delayed branch slots if supported. */
747 int flag_delayed_branch;
749 /* Nonzero if we are compiling pure (sharable) code.
750 Value is 1 if we are doing "small" pic; value is 2 if we're doing
755 /* Nonzero if we are compiling position independent code for executable.
756 The value is 1 if we are doing "small" pic; value is 2 if we're doing
761 /* Nonzero if we are compiling code for a shared library, zero for
766 /* Set to the default thread-local storage (tls) model to use. */
768 enum tls_model flag_tls_default = TLS_MODEL_GLOBAL_DYNAMIC;
770 /* Nonzero means generate extra code for exception handling and enable
771 exception handling. */
775 /* Nonzero means generate frame unwind info table when supported. */
777 int flag_unwind_tables = 0;
779 /* Nonzero means generate frame unwind info table exact at each insn boundary */
781 int flag_asynchronous_unwind_tables = 0;
783 /* Nonzero means don't place uninitialized global data in common storage
788 /* Nonzero means change certain warnings into errors.
789 Usually these are warnings about failure to conform to some standard. */
791 int flag_pedantic_errors = 0;
793 /* flag_schedule_insns means schedule insns within basic blocks (before
795 flag_schedule_insns_after_reload means schedule insns after
798 int flag_schedule_insns = 0;
799 int flag_schedule_insns_after_reload = 0;
801 /* When flag_schedule_insns_after_reload is set, use EBB scheduler. */
802 int flag_sched2_use_superblocks = 0;
804 /* When flag_schedule_insns_after_reload is set, construct traces and EBB
806 int flag_sched2_use_traces = 0;
808 /* The following flags have effect only for scheduling before register
811 flag_schedule_interblock means schedule insns across basic blocks.
812 flag_schedule_speculative means allow speculative motion of non-load insns.
813 flag_schedule_speculative_load means allow speculative motion of some
815 flag_schedule_speculative_load_dangerous allows speculative motion of more
818 int flag_schedule_interblock = 1;
819 int flag_schedule_speculative = 1;
820 int flag_schedule_speculative_load = 0;
821 int flag_schedule_speculative_load_dangerous = 0;
823 int flag_single_precision_constant;
825 /* flag_branch_on_count_reg means try to replace add-1,compare,branch tupple
826 by a cheaper branch on a count register. */
827 int flag_branch_on_count_reg = 1;
829 /* -finhibit-size-directive inhibits output of .size for ELF.
830 This is used only for compiling crtstuff.c,
831 and it may be extended to other effects
832 needed for crtstuff.c on other systems. */
833 int flag_inhibit_size_directive = 0;
835 /* -fverbose-asm causes extra commentary information to be produced in
836 the generated assembly code (to make it more readable). This option
837 is generally only of use to those who actually need to read the
838 generated assembly code (perhaps while debugging the compiler itself).
839 -fno-verbose-asm, the default, causes the extra information
840 to be omitted and is useful when comparing two assembler files. */
842 int flag_verbose_asm = 0;
844 /* -dA causes debug commentary information to be produced in
845 the generated assembly code (to make it more readable). This option
846 is generally only of use to those who actually need to read the
847 generated assembly code (perhaps while debugging the compiler itself).
848 Currently, this switch is only used by dwarfout.c; however, it is intended
849 to be a catchall for printing debug information in the assembler file. */
851 int flag_debug_asm = 0;
853 /* -dP causes the rtl to be emitted as a comment in assembly. */
855 int flag_dump_rtl_in_asm = 0;
857 /* -fgnu-linker specifies use of the GNU linker for initializations.
858 (Or, more generally, a linker that handles initializations.)
859 -fno-gnu-linker says that collect2 will be used. */
861 int flag_gnu_linker = 0;
863 int flag_gnu_linker = 1;
866 /* Nonzero means put zero initialized data in the bss section. */
867 int flag_zero_initialized_in_bss = 1;
872 /* Enable ssa conditional constant propagation. */
873 int flag_ssa_ccp = 0;
875 /* Enable ssa aggressive dead code elimination. */
876 int flag_ssa_dce = 0;
878 /* Tag all structures with __attribute__(packed). */
879 int flag_pack_struct = 0;
881 /* Emit code to check for stack overflow; also may cause large objects
882 to be allocated dynamically. */
883 int flag_stack_check;
885 /* When non-NULL, indicates that whenever space is allocated on the
886 stack, the resulting stack pointer must not pass this
887 address---that is, for stacks that grow downward, the stack pointer
888 must always be greater than or equal to this address; for stacks
889 that grow upward, the stack pointer must be less than this address.
890 At present, the rtx may be either a REG or a SYMBOL_REF, although
891 the support provided depends on the backend. */
894 /* 0 if pointer arguments may alias each other. True in C.
895 1 if pointer arguments may not alias each other but may alias
897 2 if pointer arguments may not alias each other and may not
898 alias global variables. True in Fortran.
899 This defaults to 0 for C. */
900 int flag_argument_noalias = 0;
902 /* Nonzero if we should do (language-dependent) alias analysis.
903 Typically, this analysis will assume that expressions of certain
904 types do not alias expressions of certain other types. Only used
905 if alias analysis (in general) is enabled. */
906 int flag_strict_aliasing = 0;
908 /* Instrument functions with calls at entry and exit, for profiling. */
909 int flag_instrument_function_entry_exit = 0;
911 /* Nonzero means ignore `#ident' directives. 0 means handle them.
912 On SVR4 targets, it also controls whether or not to emit a
913 string identifying the compiler. */
915 int flag_no_ident = 0;
917 /* This will perform a peephole pass before sched2. */
918 int flag_peephole2 = 0;
920 /* This will try to guess branch probabilities. */
921 int flag_guess_branch_prob = 0;
923 /* -fcheck-bounds causes gcc to generate array bounds checks.
924 For C, C++, ObjC: defaults to off.
925 For Java: defaults to on.
926 For Fortran: defaults to off. */
927 int flag_bounds_check = 0;
929 /* This will attempt to merge constant section constants, if 1 only
930 string constants and constants from constant pool, if 2 also constant
932 int flag_merge_constants = 1;
934 /* If one, renumber instruction UIDs to reduce the number of
935 unused UIDs if there are a lot of instructions. If greater than
936 one, unconditionally renumber instruction UIDs. */
937 int flag_renumber_insns = 1;
939 /* If nonzero, use the graph coloring register allocator. */
940 int flag_new_regalloc = 0;
942 /* Nonzero if we perform superblock formation. */
946 /* Nonzero if we perform whole unit at a time compilation. */
948 int flag_unit_at_a_time = 0;
950 /* Values of the -falign-* flags: how much to align labels in code.
951 0 means `use default', 1 means `don't align'.
952 For each variable, there is an _log variant which is the power
953 of two not less than the variable, for .align output. */
957 int align_loops_max_skip;
960 int align_jumps_max_skip;
962 int align_labels_log;
963 int align_labels_max_skip;
965 int align_functions_log;
967 /* Like align_functions_log above, but used by front-ends to force the
968 minimum function alignment. Zero means no alignment is forced. */
969 int force_align_functions_log;
971 /* Table of supported debugging formats. */
974 const char *const arg;
975 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
976 constant expression, we use NO_DEBUG in its place. */
977 const enum debug_info_type debug_type;
978 const int use_extensions_p;
979 const char *const description;
983 { "", NO_DEBUG, DEFAULT_GDB_EXTENSIONS,
984 N_("Generate debugging info in default format") },
985 { "gdb", NO_DEBUG, 1, N_("Generate debugging info in default extended format") },
986 #ifdef DBX_DEBUGGING_INFO
987 { "stabs", DBX_DEBUG, 0, N_("Generate STABS format debug info") },
988 { "stabs+", DBX_DEBUG, 1, N_("Generate extended STABS format debug info") },
990 #ifdef DWARF_DEBUGGING_INFO
991 { "dwarf", DWARF_DEBUG, 0, N_("Generate DWARF-1 format debug info") },
992 { "dwarf+", DWARF_DEBUG, 1,
993 N_("Generate extended DWARF-1 format debug info") },
995 #ifdef DWARF2_DEBUGGING_INFO
996 { "dwarf-2", DWARF2_DEBUG, 0, N_("Generate DWARF-2 debug info") },
998 #ifdef XCOFF_DEBUGGING_INFO
999 { "xcoff", XCOFF_DEBUG, 0, N_("Generate XCOFF format debug info") },
1000 { "xcoff+", XCOFF_DEBUG, 1, N_("Generate extended XCOFF format debug info") },
1002 #ifdef SDB_DEBUGGING_INFO
1003 { "coff", SDB_DEBUG, 0, N_("Generate COFF format debug info") },
1005 #ifdef VMS_DEBUGGING_INFO
1006 { "vms", VMS_DEBUG, 0, N_("Generate VMS format debug info") },
1013 const char *const string;
1014 int *const variable;
1016 const char *const description;
1018 lang_independent_options;
1020 /* Nonzero if signed arithmetic overflow should trap. */
1023 /* Nonzero if signed arithmetic overflow should wrap around. */
1026 /* Add or remove a leading underscore from user symbols. */
1027 int flag_leading_underscore = -1;
1029 /* The user symbol prefix after having resolved same. */
1030 const char *user_label_prefix;
1032 static const param_info lang_independent_params[] = {
1033 #define DEFPARAM(ENUM, OPTION, HELP, DEFAULT) \
1034 { OPTION, DEFAULT, HELP },
1035 #include "params.def"
1040 /* Used for the f_options array temporarily. */
1041 static int flag_dummy;
1043 /* Table of language-independent -f options.
1044 STRING is the option name. VARIABLE is the address of the variable.
1045 ON_VALUE is the value to store in VARIABLE
1046 if `-fSTRING' is seen as an option.
1047 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
1049 static const lang_independent_options f_options[] =
1051 {"eliminate-dwarf2-dups", &flag_dummy, 1,
1052 N_("Perform DWARF2 duplicate elimination") },
1053 {"eliminate-unused-debug-types", &flag_dummy, 1,
1054 N_("Perform unused type elimination in debug info") },
1055 {"float-store", &flag_dummy, 1,
1056 N_("Do not store floats in registers") },
1057 {"defer-pop", &flag_dummy, 1,
1058 N_("Defer popping functions args from stack until later") },
1059 {"omit-frame-pointer", &flag_dummy, 1,
1060 N_("When possible do not generate stack frames") },
1061 {"optimize-sibling-calls", &flag_dummy, 1,
1062 N_("Optimize sibling and tail recursive calls") },
1063 {"tracer", &flag_dummy, 1,
1064 N_("Perform superblock formation via tail duplication") },
1065 {"unit-at-a-time", &flag_dummy, 1,
1066 N_("Compile whole compilation unit at a time") },
1067 {"cse-follow-jumps", &flag_dummy, 1,
1068 N_("When running CSE, follow jumps to their targets") },
1069 {"cse-skip-blocks", &flag_dummy, 1,
1070 N_("When running CSE, follow conditional jumps") },
1071 {"expensive-optimizations", &flag_dummy, 1,
1072 N_("Perform a number of minor, expensive optimizations") },
1073 {"thread-jumps", &flag_dummy, 1,
1074 N_("Perform jump threading optimizations") },
1075 {"strength-reduce", &flag_dummy, 1,
1076 N_("Perform strength reduction optimizations") },
1077 {"unroll-loops", &flag_dummy, 1,
1078 N_("Perform loop unrolling when iteration count is known") },
1079 {"unroll-all-loops", &flag_dummy, 1,
1080 N_("Perform loop unrolling for all loops") },
1081 {"old-unroll-loops", &flag_dummy, 1,
1082 N_("Perform loop unrolling when iteration count is known") },
1083 {"old-unroll-all-loops", &flag_dummy, 1,
1084 N_("Perform loop unrolling for all loops") },
1085 {"peel-loops", &flag_dummy, 1,
1086 N_("Perform loop peeling") },
1087 {"unswitch-loops", &flag_dummy, 1,
1088 N_("Perform loop unswitching") },
1089 {"prefetch-loop-arrays", &flag_dummy, 1,
1090 N_("Generate prefetch instructions, if available, for arrays in loops") },
1091 {"move-all-movables", &flag_dummy, 1,
1092 N_("Force all loop invariant computations out of loops") },
1093 {"reduce-all-givs", &flag_dummy, 1,
1094 N_("Strength reduce all loop general induction variables") },
1095 {"writable-strings", &flag_dummy, 1,
1096 N_("Store strings in writable data section") },
1097 {"peephole", &flag_dummy, 0,
1098 N_("Enable machine specific peephole optimizations") },
1099 {"force-mem", &flag_dummy, 1,
1100 N_("Copy memory operands into registers before using") },
1101 {"force-addr", &flag_dummy, 1,
1102 N_("Copy memory address constants into regs before using") },
1103 {"function-cse", &flag_dummy, 0,
1104 N_("Allow function addresses to be held in registers") },
1105 {"inline-functions", &flag_dummy, 1,
1106 N_("Integrate simple functions into their callers") },
1107 {"keep-inline-functions", &flag_dummy, 1,
1108 N_("Generate code for funcs even if they are fully inlined") },
1109 {"inline", &flag_dummy, 0,
1110 N_("Pay attention to the 'inline' keyword") },
1111 {"keep-static-consts", &flag_dummy, 1,
1112 N_("Emit static const variables even if they are not used") },
1113 {"syntax-only", &flag_dummy, 1,
1114 N_("Check for syntax errors, then stop") },
1115 {"shared-data", &flag_dummy, 1,
1116 N_("Mark data as shared rather than private") },
1117 {"caller-saves", &flag_dummy, 1,
1118 N_("Enable saving registers around function calls") },
1119 {"pcc-struct-return", &flag_dummy, 1,
1120 N_("Return 'short' aggregates in memory, not registers") },
1121 {"reg-struct-return", &flag_dummy, 0,
1122 N_("Return 'short' aggregates in registers") },
1123 {"delayed-branch", &flag_dummy, 1,
1124 N_("Attempt to fill delay slots of branch instructions") },
1125 {"gcse", &flag_dummy, 1,
1126 N_("Perform the global common subexpression elimination") },
1127 {"gcse-lm", &flag_dummy, 1,
1128 N_("Perform enhanced load motion during global subexpression elimination") },
1129 {"gcse-sm", &flag_dummy, 1,
1130 N_("Perform store motion after global subexpression elimination") },
1131 {"branch-target-load-optimize", &flag_dummy, 1,
1132 N_("Perform branch target load optimization before prologue / epilogue threading") },
1133 {"branch-target-load-optimize2", &flag_dummy, 1,
1134 N_("Perform branch target load optimization after prologue / epilogue threading") },
1135 {"loop-optimize", &flag_dummy, 1,
1136 N_("Perform the loop optimizations") },
1137 {"crossjumping", &flag_dummy, 1,
1138 N_("Perform cross-jumping optimization") },
1139 {"if-conversion", &flag_dummy, 1,
1140 N_("Perform conversion of conditional jumps to branchless equivalents") },
1141 {"if-conversion2", &flag_dummy, 1,
1142 N_("Perform conversion of conditional jumps to conditional execution") },
1143 {"rerun-cse-after-loop", &flag_dummy, 1,
1144 N_("Run CSE pass after loop optimizations") },
1145 {"rerun-loop-opt", &flag_dummy, 1,
1146 N_("Run the loop optimizer twice") },
1147 {"delete-null-pointer-checks", &flag_dummy, 1,
1148 N_("Delete useless null pointer checks") },
1149 {"schedule-insns", &flag_dummy, 1,
1150 N_("Reschedule instructions before register allocation") },
1151 {"schedule-insns2", &flag_dummy, 1,
1152 N_("Reschedule instructions after register allocation") },
1153 {"sched-interblock",&flag_dummy, 1,
1154 N_("Enable scheduling across basic blocks") },
1155 {"sched-spec",&flag_dummy, 1,
1156 N_("Allow speculative motion of non-loads") },
1157 {"sched-spec-load",&flag_dummy, 1,
1158 N_("Allow speculative motion of some loads") },
1159 {"sched-spec-load-dangerous",&flag_dummy, 1,
1160 N_("Allow speculative motion of more loads") },
1161 {"sched2-use-superblocks", &flag_dummy, 1,
1162 N_("If scheduling post reload, do superblock scheduling") },
1163 {"sched2-use-traces", &flag_dummy, 1,
1164 N_("If scheduling post reload, do trace scheduling") },
1165 {"branch-count-reg",&flag_dummy, 1,
1166 N_("Replace add,compare,branch with branch on count reg") },
1167 {"pic", &flag_dummy, 1,
1168 N_("Generate position independent code, if possible") },
1169 {"PIC", &flag_dummy, 2, ""},
1170 {"pie", &flag_dummy, 1,
1171 N_("Generate position independent code for executables, if possible") },
1172 {"PIE", &flag_dummy, 2, ""},
1173 {"exceptions", &flag_dummy, 1,
1174 N_("Enable exception handling") },
1175 {"unwind-tables", &flag_dummy, 1,
1176 N_("Just generate unwind tables for exception handling") },
1177 {"asynchronous-unwind-tables", &flag_dummy, 1,
1178 N_("Generate unwind tables exact at each instruction boundary") },
1179 {"non-call-exceptions", &flag_dummy, 1,
1180 N_("Support synchronous non-call exceptions") },
1181 {"profile-arcs", &flag_dummy, 1,
1182 N_("Insert arc based program profiling code") },
1183 {"test-coverage", &flag_dummy, 1,
1184 N_("Create data files needed by gcov") },
1185 {"branch-probabilities", &flag_dummy, 1,
1186 N_("Use profiling information for branch probabilities") },
1187 {"profile", &flag_dummy, 1,
1188 N_("Enable basic program profiling code") },
1189 {"reorder-blocks", &flag_dummy, 1,
1190 N_("Reorder basic blocks to improve code placement") },
1191 {"reorder-functions", &flag_dummy, 1,
1192 N_("Reorder functions to improve code placement") },
1193 {"rename-registers", &flag_dummy, 1,
1194 N_("Do the register renaming optimization pass") },
1195 {"cprop-registers", &flag_dummy, 1,
1196 N_("Do the register copy-propagation optimization pass") },
1197 {"common", &flag_dummy, 0,
1198 N_("Do not put uninitialized globals in the common section") },
1199 {"inhibit-size-directive", &flag_dummy, 1,
1200 N_("Do not generate .size directives") },
1201 {"function-sections", &flag_dummy, 1,
1202 N_("place each function into its own section") },
1203 {"data-sections", &flag_dummy, 1,
1204 N_("place data items into their own section") },
1205 {"verbose-asm", &flag_dummy, 1,
1206 N_("Add extra commentary to assembler output") },
1207 {"gnu-linker", &flag_dummy, 1,
1208 N_("Output GNU ld formatted global initializers") },
1209 {"regmove", &flag_dummy, 1,
1210 N_("Enables a register move optimization") },
1211 {"optimize-register-move", &flag_dummy, 1,
1212 N_("Do the full regmove optimization pass") },
1213 {"pack-struct", &flag_dummy, 1,
1214 N_("Pack structure members together without holes") },
1215 {"stack-check", &flag_dummy, 1,
1216 N_("Insert stack checking code into the program") },
1217 {"argument-alias", &flag_dummy, 0,
1218 N_("Specify that arguments may alias each other & globals") },
1219 {"argument-noalias", &flag_dummy, 1,
1220 N_("Assume arguments may alias globals but not each other") },
1221 {"argument-noalias-global", &flag_dummy, 2,
1222 N_("Assume arguments do not alias each other or globals") },
1223 {"strict-aliasing", &flag_dummy, 1,
1224 N_("Assume strict aliasing rules apply") },
1225 {"align-loops", &flag_dummy, 0,
1226 N_("Align the start of loops") },
1227 {"align-jumps", &flag_dummy, 0,
1228 N_("Align labels which are only reached by jumping") },
1229 {"align-labels", &flag_dummy, 0,
1230 N_("Align all labels") },
1231 {"align-functions", &flag_dummy, 0,
1232 N_("Align the start of functions") },
1233 {"merge-constants", &flag_dummy, 1,
1234 N_("Attempt to merge identical constants across compilation units") },
1235 {"merge-all-constants", &flag_dummy, 2,
1236 N_("Attempt to merge identical constants and constant variables") },
1237 {"dump-unnumbered", &flag_dummy, 1,
1238 N_("Suppress output of instruction numbers and line number notes in debugging dumps") },
1239 {"instrument-functions", &flag_dummy, 1,
1240 N_("Instrument function entry/exit with profiling calls") },
1241 {"zero-initialized-in-bss", &flag_dummy, 1,
1242 N_("Put zero initialized data in the bss section") },
1243 {"ssa", &flag_dummy, 1,
1244 N_("Enable SSA optimizations") },
1245 {"ssa-ccp", &flag_dummy, 1,
1246 N_("Enable SSA conditional constant propagation") },
1247 {"ssa-dce", &flag_dummy, 1,
1248 N_("Enable aggressive SSA dead code elimination") },
1249 {"leading-underscore", &flag_dummy, 1,
1250 N_("External symbols have a leading underscore") },
1251 {"ident", &flag_dummy, 0,
1252 N_("Process #ident directives") },
1253 { "peephole2", &flag_dummy, 1,
1254 N_("Enables an rtl peephole pass run before sched2") },
1255 {"finite-math-only", &flag_dummy, 1,
1256 N_("Assume no NaNs or +-Infs are generated") },
1257 { "guess-branch-probability", &flag_dummy, 1,
1258 N_("Enables guessing of branch probabilities") },
1259 {"math-errno", &flag_dummy, 1,
1260 N_("Set errno after built-in math functions") },
1261 {"trapping-math", &flag_dummy, 1,
1262 N_("Floating-point operations can trap") },
1263 {"unsafe-math-optimizations", &flag_dummy, 1,
1264 N_("Allow math optimizations that may violate IEEE or ANSI standards") },
1265 {"signaling-nans", &flag_dummy, 1,
1266 N_("Disable optimizations observable by IEEE signaling NaNs") },
1267 {"bounds-check", &flag_dummy, 1,
1268 N_("Generate code to check bounds before indexing arrays") },
1269 {"single-precision-constant", &flag_dummy, 1,
1270 N_("Convert floating point constant to single precision constant") },
1271 {"time-report", &flag_dummy, 1,
1272 N_("Report time taken by each compiler pass at end of run") },
1273 {"mem-report", &flag_dummy, 1,
1274 N_("Report on permanent memory allocation at end of run") },
1275 { "trapv", &flag_dummy, 1,
1276 N_("Trap for signed overflow in addition / subtraction / multiplication") },
1277 { "wrapv", &flag_dummy, 1,
1278 N_("Assume signed arithmetic overflow wraps around") },
1279 { "new-ra", &flag_dummy, 1,
1280 N_("Use graph coloring register allocation.") },
1283 /* Table of language-specific options. */
1285 static const struct lang_opt
1287 const char *const option;
1288 const char *const description;
1290 documented_lang_options[] =
1292 /* In order not to overload the --help output, the convention
1293 used here is to only describe those options which are not
1294 enabled by default. */
1297 N_("Compile just for ISO C90") },
1299 N_("Determine language standard") },
1301 { "-fsigned-bitfields", "" },
1302 { "-funsigned-bitfields",
1303 N_("Make bit-fields by unsigned by default") },
1304 { "-fno-signed-bitfields", "" },
1305 { "-fno-unsigned-bitfields","" },
1307 N_("Make 'char' be signed by default") },
1308 { "-funsigned-char",
1309 N_("Make 'char' be unsigned by default") },
1310 { "-fno-signed-char", "" },
1311 { "-fno-unsigned-char", "" },
1315 N_("Do not recognize the 'asm' keyword") },
1316 { "-fbuiltin", "" },
1318 N_("Do not recognize any built in functions") },
1320 N_("Assume normal C execution environment") },
1321 { "-fno-hosted", "" },
1323 N_("Assume that standard libraries & main might not exist") },
1324 { "-fno-freestanding", "" },
1325 { "-fcond-mismatch",
1326 N_("Allow different types as args of ? operator") },
1327 { "-fno-cond-mismatch", "" },
1328 { "-fdollars-in-identifiers",
1329 N_("Allow the use of $ inside identifiers") },
1330 { "-fno-dollars-in-identifiers", "" },
1331 { "-fpreprocessed", "" },
1332 { "-fno-preprocessed", "" },
1334 N_("Use the same size for double as for float") },
1335 { "-fno-short-double", "" },
1337 N_("Use the smallest fitting integer to hold enums") },
1338 { "-fno-short-enums", "" },
1340 N_("Override the underlying type for wchar_t to `unsigned short'") },
1341 { "-fno-short-wchar", "" },
1344 N_("Enable most warning messages") },
1345 { "-Wbad-function-cast",
1346 N_("Warn about casting functions to incompatible types") },
1347 { "-Wno-bad-function-cast", "" },
1348 { "-Wmissing-format-attribute",
1349 N_("Warn about functions which might be candidates for format attributes") },
1350 { "-Wno-missing-format-attribute", "" },
1352 N_("Warn about casts which discard qualifiers") },
1353 { "-Wno-cast-qual", "" },
1354 { "-Wchar-subscripts",
1355 N_("Warn about subscripts whose type is 'char'") },
1356 { "-Wno-char-subscripts", "" },
1358 N_("Warn if nested comments are detected") },
1359 { "-Wno-comment", "" },
1361 N_("Warn if nested comments are detected") },
1362 { "-Wno-comments", "" },
1364 N_("Warn about possibly confusing type conversions") },
1365 { "-Wno-conversion", "" },
1366 { "-Wdiv-by-zero", "" },
1367 { "-Wno-div-by-zero",
1368 N_("Do not warn about compile-time integer division by zero") },
1370 N_("Warn about testing equality of floating point numbers") },
1371 { "-Wno-float-equal", "" },
1373 N_("Warn about printf/scanf/strftime/strfmon format anomalies") },
1374 { "-Wno-format", "" },
1375 { "-Wformat-extra-args", "" },
1376 { "-Wno-format-extra-args",
1377 N_("Don't warn about too many arguments to format functions") },
1378 { "-Wformat-nonliteral",
1379 N_("Warn about non-string-literal format strings") },
1380 { "-Wno-format-nonliteral", "" },
1381 { "-Wformat-security",
1382 N_("Warn about possible security problems with format functions") },
1383 { "-Wno-format-security", "" },
1384 { "-Wformat-y2k", "" },
1385 { "-Wno-format-y2k",
1386 N_("Don't warn about strftime formats yielding 2 digit years") },
1387 { "-Wimplicit-function-declaration",
1388 N_("Warn about implicit function declarations") },
1389 { "-Wno-implicit-function-declaration", "" },
1390 { "-Werror-implicit-function-declaration", "" },
1392 N_("Warn when a declaration does not specify a type") },
1393 { "-Wno-implicit-int", "" },
1394 { "-Wimplicit", "" },
1395 { "-Wno-implicit", "" },
1397 N_("Warn about the use of the #import directive") },
1398 { "-Wno-import", "" },
1400 N_("Warn about PCH files that are found but not used") },
1401 { "-Wlong-long","" },
1403 N_("Do not warn about using 'long long' when -pedantic") },
1405 N_("Warn about suspicious declarations of main") },
1406 { "-Wno-main", "" },
1407 { "-Wmissing-braces",
1408 N_("Warn about possibly missing braces around initializers") },
1409 { "-Wno-missing-braces", "" },
1410 { "-Wmissing-declarations",
1411 N_("Warn about global funcs without previous declarations") },
1412 { "-Wno-missing-declarations", "" },
1413 { "-Wmissing-prototypes",
1414 N_("Warn about global funcs without prototypes") },
1415 { "-Wno-missing-prototypes", "" },
1417 N_("Warn about use of multicharacter literals") },
1418 { "-Wno-multichar", "" },
1419 { "-Wnested-externs",
1420 N_("Warn about externs not at file scope level") },
1421 { "-Wno-nested-externs", "" },
1423 N_("Warn about possible missing parentheses") },
1424 { "-Wno-parentheses", "" },
1425 { "-Wpointer-arith",
1426 N_("Warn about function pointer arithmetic") },
1427 { "-Wno-pointer-arith", "" },
1428 { "-Wredundant-decls",
1429 N_("Warn about multiple declarations of the same object") },
1430 { "-Wno-redundant-decls", "" },
1432 N_("Warn whenever a function's return-type defaults to int") },
1433 { "-Wno-return-type", "" },
1434 { "-Wsequence-point",
1435 N_("Warn about possible violations of sequence point rules") },
1436 { "-Wno-sequence-point", "" },
1438 N_("Warn about signed/unsigned comparisons") },
1439 { "-Wno-sign-compare", "" },
1440 { "-Wstrict-prototypes",
1441 N_("Warn about non-prototyped function decls") },
1442 { "-Wno-strict-prototypes", "" },
1444 N_("Warn about constructs whose meanings change in ISO C") },
1445 { "-Wno-traditional", "" },
1447 N_("Warn when trigraphs are encountered") },
1448 { "-Wno-trigraphs", "" },
1450 { "-Wno-undef", "" },
1451 { "-Wunknown-pragmas",
1452 N_("Warn about unrecognized pragmas") },
1453 { "-Wno-unknown-pragmas", "" },
1454 { "-Wwrite-strings",
1455 N_("Mark strings as 'const char *'") },
1456 { "-Wno-write-strings", "" },
1458 #define DEFINE_LANG_NAME(NAME) { NULL, NAME },
1460 #include "options_.h"
1464 /* Here is a table, controlled by the tm.h file, listing each -m switch
1465 and which bits in `target_switches' it should set or clear.
1466 If VALUE is positive, it is bits to set.
1467 If VALUE is negative, -VALUE is bits to clear.
1468 (The sign bit is not used so there is no confusion.) */
1472 const char *const name;
1474 const char *const description;
1476 target_switches[] = TARGET_SWITCHES;
1478 /* This table is similar, but allows the switch to have a value. */
1480 #ifdef TARGET_OPTIONS
1483 const char *const prefix;
1484 const char **const variable;
1485 const char *const description;
1486 const char *const value;
1488 target_options[] = TARGET_OPTIONS;
1491 /* Options controlling warnings. */
1493 /* Nonzero means warn about function definitions that default the return type
1494 or that use a null return and have a return-type other than void. */
1496 int warn_return_type;
1498 /* Used for the -W options array temporarily. */
1499 static int warn_dummy;
1501 /* Like f_options, but for -W. */
1503 static const lang_independent_options W_options[] =
1505 {"unused-function", &warn_dummy, 1,
1506 N_("Warn when a function is unused") },
1507 {"unused-label", &warn_dummy, 1,
1508 N_("Warn when a label is unused") },
1509 {"unused-parameter", &warn_dummy, 1,
1510 N_("Warn when a function parameter is unused") },
1511 {"unused-variable", &warn_dummy, 1,
1512 N_("Warn when a variable is unused") },
1513 {"unused-value", &warn_dummy, 1,
1514 N_("Warn when an expression value is unused") },
1515 {"system-headers", &warn_dummy, 1,
1516 N_("Do not suppress warnings from system headers") },
1517 {"error", &warn_dummy, 1,
1518 N_("Treat all warnings as errors") },
1519 {"shadow", &warn_dummy, 1,
1520 N_("Warn when one local variable shadows another") },
1521 {"switch", &warn_dummy, 1,
1522 N_("Warn about enumerated switches, with no default, missing a case") },
1523 {"switch-default", &warn_dummy, 1,
1524 N_("Warn about enumerated switches missing a default case") },
1525 {"switch-enum", &warn_dummy, 1,
1526 N_("Warn about all enumerated switches missing a specific case") },
1527 {"aggregate-return", &warn_dummy, 1,
1528 N_("Warn about returning structures, unions or arrays") },
1529 {"cast-align", &warn_dummy, 1,
1530 N_("Warn about pointer casts which increase alignment") },
1531 {"unreachable-code", &warn_dummy, 1,
1532 N_("Warn about code that will never be executed") },
1533 {"uninitialized", &warn_dummy, 1,
1534 N_("Warn about uninitialized automatic variables") },
1535 {"inline", &warn_dummy, 1,
1536 N_("Warn when an inlined function cannot be inlined") },
1537 {"packed", &warn_dummy, 1,
1538 N_("Warn when the packed attribute has no effect on struct layout") },
1539 {"padded", &warn_dummy, 1,
1540 N_("Warn when padding is required to align struct members") },
1541 {"disabled-optimization", &warn_dummy, 1,
1542 N_("Warn when an optimization pass is disabled") },
1543 {"deprecated-declarations", &warn_dummy, 1,
1544 N_("Warn about uses of __attribute__((deprecated)) declarations") },
1545 {"missing-noreturn", &warn_dummy, 1,
1546 N_("Warn about functions which might be candidates for attribute noreturn") },
1547 {"strict-aliasing", &warn_dummy, 1,
1548 N_ ("Warn about code which might break the strict aliasing rules") }
1551 /* Output files for assembler code (real compiler output)
1552 and debugging dumps. */
1555 FILE *aux_info_file;
1556 FILE *rtl_dump_file = NULL;
1558 /* Decode the string P as an integral parameter.
1559 If the string is indeed an integer return its numeric value else
1560 issue an Invalid Option error for the option PNAME and return DEFVAL.
1561 If PNAME is zero just return DEFVAL, do not call error. */
1564 read_integral_parameter (const char *p, const char *pname, const int defval)
1566 const char *endp = p;
1570 if (ISDIGIT (*endp))
1579 error ("invalid option argument `%s'", pname);
1586 /* Return the logarithm of X, base 2, considering X unsigned,
1587 if X is a power of 2. Otherwise, returns -1.
1589 This should be used via the `exact_log2' macro. */
1592 exact_log2_wide (unsigned HOST_WIDE_INT x)
1595 /* Test for 0 or a power of 2. */
1596 if (x == 0 || x != (x & -x))
1598 while ((x >>= 1) != 0)
1603 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1604 If X is 0, return -1.
1606 This should be used via the floor_log2 macro. */
1609 floor_log2_wide (unsigned HOST_WIDE_INT x)
1618 /* Handler for fatal signals, such as SIGSEGV. These are transformed
1619 into ICE messages, which is much more user friendly. In case the
1620 error printer crashes, reset the signal to prevent infinite recursion. */
1623 crash_signal (int signo)
1625 signal (signo, SIG_DFL);
1626 internal_error ("%s", strsignal (signo));
1629 /* Arrange to dump core on error. (The regular error message is still
1630 printed first, except in the case of abort().) */
1633 setup_core_dumping (void)
1636 signal (SIGABRT, SIG_DFL);
1638 #if defined(HAVE_SETRLIMIT)
1641 if (getrlimit (RLIMIT_CORE, &rlim) != 0)
1642 fatal_error ("getting core file size maximum limit: %m");
1643 rlim.rlim_cur = rlim.rlim_max;
1644 if (setrlimit (RLIMIT_CORE, &rlim) != 0)
1645 fatal_error ("setting core file size limit to maximum: %m");
1648 diagnostic_abort_on_error (global_dc);
1652 /* Strip off a legitimate source ending from the input string NAME of
1653 length LEN. Rather than having to know the names used by all of
1654 our front ends, we strip off an ending of a period followed by
1655 up to five characters. (Java uses ".class".) */
1658 strip_off_ending (char *name, int len)
1661 for (i = 2; i < 6 && len > i; i++)
1663 if (name[len - i] == '.')
1665 name[len - i] = '\0';
1671 /* Output a quoted string. */
1674 output_quoted_string (FILE *asm_file, const char *string)
1676 #ifdef OUTPUT_QUOTED_STRING
1677 OUTPUT_QUOTED_STRING (asm_file, string);
1681 putc ('\"', asm_file);
1682 while ((c = *string++) != 0)
1686 if (c == '\"' || c == '\\')
1687 putc ('\\', asm_file);
1691 fprintf (asm_file, "\\%03o", (unsigned char) c);
1693 putc ('\"', asm_file);
1697 /* Output NAME into FILE after having turned it into something
1698 usable as an identifier in a target's assembly file. */
1700 output_clean_symbol_name (FILE *file, const char *name)
1702 /* Make a copy of NAME. */
1703 char *id = xstrdup (name);
1705 /* Make it look like a valid identifier for an assembler. */
1706 clean_symbol_name (id);
1713 /* Output a file name in the form wanted by System V. */
1716 output_file_directive (FILE *asm_file, const char *input_name)
1718 int len = strlen (input_name);
1719 const char *na = input_name + len;
1721 /* NA gets INPUT_NAME sans directory names. */
1722 while (na > input_name)
1724 if (IS_DIR_SEPARATOR (na[-1]))
1729 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1730 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
1732 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1733 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1735 fprintf (asm_file, "\t.file\t");
1736 output_quoted_string (asm_file, na);
1737 fputc ('\n', asm_file);
1742 /* Routine to open a dump file. Return true if the dump file is enabled. */
1745 open_dump_file (enum dump_file_index index, tree decl)
1748 const char *open_arg;
1751 if (! dump_file[index].enabled)
1754 timevar_push (TV_DUMP);
1755 if (rtl_dump_file != NULL)
1756 fclose (rtl_dump_file);
1758 sprintf (seq, DUMPFILE_FORMAT, index);
1760 if (! dump_file[index].initialized)
1762 /* If we've not initialized the files, do so now. */
1763 if (graph_dump_format != no_graph
1764 && dump_file[index].graph_dump_p)
1766 dump_name = concat (seq, dump_file[index].extension, NULL);
1767 clean_graph_dump_file (dump_base_name, dump_name);
1770 dump_file[index].initialized = 1;
1776 dump_name = concat (dump_base_name, seq,
1777 dump_file[index].extension, NULL);
1779 rtl_dump_file = fopen (dump_name, open_arg);
1780 if (rtl_dump_file == NULL)
1781 fatal_error ("can't open %s: %m", dump_name);
1786 fprintf (rtl_dump_file, "\n;; Function %s%s\n\n",
1787 (*lang_hooks.decl_printable_name) (decl, 2),
1788 cfun->function_frequency == FUNCTION_FREQUENCY_HOT
1790 : cfun->function_frequency == FUNCTION_FREQUENCY_UNLIKELY_EXECUTED
1791 ? " (unlikely executed)"
1794 timevar_pop (TV_DUMP);
1798 /* Routine to close a dump file. */
1801 close_dump_file (enum dump_file_index index,
1802 void (*func) (FILE *, rtx),
1805 if (! rtl_dump_file)
1808 timevar_push (TV_DUMP);
1810 && graph_dump_format != no_graph
1811 && dump_file[index].graph_dump_p)
1816 sprintf (seq, DUMPFILE_FORMAT, index);
1817 suffix = concat (seq, dump_file[index].extension, NULL);
1818 print_rtl_graph_with_bb (dump_base_name, suffix, insns);
1823 func (rtl_dump_file, insns);
1825 fflush (rtl_dump_file);
1826 fclose (rtl_dump_file);
1828 rtl_dump_file = NULL;
1829 timevar_pop (TV_DUMP);
1832 /* Do any final processing required for the declarations in VEC, of
1833 which there are LEN. We write out inline functions and variables
1834 that have been deferred until this point, but which are required.
1835 Returns nonzero if anything was put out. */
1838 wrapup_global_declarations (tree *vec, int len)
1843 int output_something = 0;
1845 for (i = 0; i < len; i++)
1849 /* We're not deferring this any longer. Assignment is
1850 conditional to avoid needlessly dirtying PCH pages. */
1851 if (DECL_DEFER_OUTPUT (decl) != 0)
1852 DECL_DEFER_OUTPUT (decl) = 0;
1854 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0)
1855 (*lang_hooks.finish_incomplete_decl) (decl);
1858 /* Now emit any global variables or functions that we have been
1859 putting off. We need to loop in case one of the things emitted
1860 here references another one which comes earlier in the list. */
1864 for (i = 0; i < len; i++)
1868 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
1871 /* Don't write out static consts, unless we still need them.
1873 We also keep static consts if not optimizing (for debugging),
1874 unless the user specified -fno-keep-static-consts.
1875 ??? They might be better written into the debug information.
1876 This is possible when using DWARF.
1878 A language processor that wants static constants to be always
1879 written out (even if it is not used) is responsible for
1880 calling rest_of_decl_compilation itself. E.g. the C front-end
1881 calls rest_of_decl_compilation from finish_decl.
1882 One motivation for this is that is conventional in some
1883 environments to write things like:
1884 static const char rcsid[] = "... version string ...";
1885 intending to force the string to be in the executable.
1887 A language processor that would prefer to have unneeded
1888 static constants "optimized away" would just defer writing
1889 them out until here. E.g. C++ does this, because static
1890 constants are often defined in header files.
1892 ??? A tempting alternative (for both C and C++) would be
1893 to force a constant to be written if and only if it is
1894 defined in a main file, as opposed to an include file. */
1896 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl))
1900 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
1902 else if (DECL_COMDAT (decl))
1904 else if (TREE_READONLY (decl) && !TREE_PUBLIC (decl)
1905 && (optimize || !flag_keep_static_consts
1906 || DECL_ARTIFICIAL (decl)))
1912 rest_of_decl_compilation (decl, NULL, 1, 1);
1916 if (TREE_CODE (decl) == FUNCTION_DECL
1917 && DECL_INITIAL (decl) != 0
1918 && DECL_SAVED_INSNS (decl) != 0
1919 && (flag_keep_inline_functions
1920 || (TREE_PUBLIC (decl) && !DECL_COMDAT (decl))
1921 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
1924 output_inline_function (decl);
1929 output_something = 1;
1933 return output_something;
1936 /* Issue appropriate warnings for the global declarations in VEC (of
1937 which there are LEN). Output debugging information for them. */
1940 check_global_declarations (tree *vec, int len)
1945 for (i = 0; i < len; i++)
1949 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
1950 && ! TREE_ASM_WRITTEN (decl))
1951 /* Cancel the RTL for this decl so that, if debugging info
1952 output for global variables is still to come,
1953 this one will be omitted. */
1954 SET_DECL_RTL (decl, NULL_RTX);
1956 /* Warn about any function
1957 declared static but not defined.
1958 We don't warn about variables,
1959 because many programs have static variables
1960 that exist only to get some text into the object file. */
1961 if (TREE_CODE (decl) == FUNCTION_DECL
1962 && (warn_unused_function
1963 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
1964 && DECL_INITIAL (decl) == 0
1965 && DECL_EXTERNAL (decl)
1966 && ! DECL_ARTIFICIAL (decl)
1967 && ! TREE_PUBLIC (decl))
1969 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
1970 pedwarn_with_decl (decl,
1971 "`%s' used but never defined");
1973 warning_with_decl (decl,
1974 "`%s' declared `static' but never defined");
1975 /* This symbol is effectively an "extern" declaration now. */
1976 TREE_PUBLIC (decl) = 1;
1977 assemble_external (decl);
1980 /* Warn about static fns or vars defined but not used. */
1981 if (((warn_unused_function && TREE_CODE (decl) == FUNCTION_DECL)
1982 || (warn_unused_variable && TREE_CODE (decl) == VAR_DECL))
1983 && ! TREE_USED (decl)
1984 /* The TREE_USED bit for file-scope decls is kept in the identifier,
1985 to handle multiple external decls in different scopes. */
1986 && ! TREE_USED (DECL_NAME (decl))
1987 && ! DECL_EXTERNAL (decl)
1988 && ! TREE_PUBLIC (decl)
1989 /* A volatile variable might be used in some non-obvious way. */
1990 && ! TREE_THIS_VOLATILE (decl)
1991 /* Global register variables must be declared to reserve them. */
1992 && ! (TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl))
1993 /* Otherwise, ask the language. */
1994 && (*lang_hooks.decls.warn_unused_global) (decl))
1995 warning_with_decl (decl, "`%s' defined but not used");
1997 /* Avoid confusing the debug information machinery when there are
1999 if (errorcount == 0 && sorrycount == 0)
2001 timevar_push (TV_SYMOUT);
2002 (*debug_hooks->global_decl) (decl);
2003 timevar_pop (TV_SYMOUT);
2008 /* Save the current INPUT_LOCATION on the top entry in the
2009 INPUT_FILE_STACK. Push a new entry for FILE and LINE, and set the
2010 INPUT_LOCATION accordingly. */
2013 push_srcloc (const char *file, int line)
2015 struct file_stack *fs;
2017 fs = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2018 fs->location = input_location;
2019 fs->next = input_file_stack;
2020 input_filename = file;
2022 input_file_stack = fs;
2023 input_file_stack_tick++;
2026 /* Pop the top entry off the stack of presently open source files.
2027 Restore the INPUT_LOCATION from the new topmost entry on the
2033 struct file_stack *fs;
2035 fs = input_file_stack;
2036 input_location = fs->location;
2037 input_file_stack = fs->next;
2039 input_file_stack_tick++;
2042 /* Compile an entire translation unit. Write a file of assembly
2043 output and various debugging dumps. */
2048 /* Initialize yet another pass. */
2050 init_final (main_input_filename);
2051 coverage_init (aux_base_name);
2053 timevar_push (TV_PARSE);
2055 /* Call the parser, which parses the entire file (calling
2056 rest_of_compilation for each function). */
2057 (*lang_hooks.parse_file) (set_yydebug);
2059 /* In case there were missing block closers,
2060 get us back to the global binding level. */
2061 (*lang_hooks.clear_binding_stack) ();
2063 /* Compilation is now finished except for writing
2064 what's left of the symbol table output. */
2065 timevar_pop (TV_PARSE);
2067 if (flag_syntax_only)
2070 (*lang_hooks.decls.final_write_globals)();
2072 /* This must occur after the loop to output deferred functions.
2073 Else the coverage initializer would not be emitted if all the
2074 functions in this compilation unit were deferred. */
2077 /* Write out any pending weak symbol declarations. */
2081 /* Do dbx symbols. */
2082 timevar_push (TV_SYMOUT);
2084 #ifdef DWARF2_UNWIND_INFO
2085 if (dwarf2out_do_frame ())
2086 dwarf2out_frame_finish ();
2089 (*debug_hooks->finish) (main_input_filename);
2090 timevar_pop (TV_SYMOUT);
2092 /* Output some stuff at end of file if nec. */
2094 dw2_output_indirect_constants ();
2096 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
2098 timevar_push (TV_DUMP);
2099 open_dump_file (DFI_bp, NULL);
2103 close_dump_file (DFI_bp, NULL, NULL_RTX);
2104 timevar_pop (TV_DUMP);
2107 targetm.asm_out.file_end ();
2109 /* Attach a special .ident directive to the end of the file to identify
2110 the version of GCC which compiled this code. The format of the .ident
2111 string is patterned after the ones produced by native SVR4 compilers. */
2114 fprintf (asm_out_file, "%s\"GCC: (GNU) %s\"\n",
2115 IDENT_ASM_OP, version_string);
2118 if (optimize > 0 && open_dump_file (DFI_combine, NULL))
2120 timevar_push (TV_DUMP);
2121 dump_combine_total_stats (rtl_dump_file);
2122 close_dump_file (DFI_combine, NULL, NULL_RTX);
2123 timevar_pop (TV_DUMP);
2127 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2128 and TYPE_DECL nodes.
2130 This does nothing for local (non-static) variables, unless the
2131 variable is a register variable with an ASMSPEC. In that case, or
2132 if the variable is not an automatic, it sets up the RTL and
2133 outputs any assembler code (label definition, storage allocation
2134 and initialization).
2136 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2137 the assembler symbol name to be used. TOP_LEVEL is nonzero
2138 if this declaration is not within a function. */
2141 rest_of_decl_compilation (tree decl,
2142 const char *asmspec,
2146 /* We deferred calling assemble_alias so that we could collect
2147 other attributes such as visibility. Emit the alias now. */
2150 alias = lookup_attribute ("alias", DECL_ATTRIBUTES (decl));
2153 alias = TREE_VALUE (TREE_VALUE (alias));
2154 alias = get_identifier (TREE_STRING_POINTER (alias));
2155 assemble_alias (decl, alias);
2159 /* Forward declarations for nested functions are not "external",
2160 but we need to treat them as if they were. */
2161 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2162 || TREE_CODE (decl) == FUNCTION_DECL)
2164 timevar_push (TV_VARCONST);
2167 make_decl_rtl (decl, asmspec);
2169 /* Don't output anything when a tentative file-scope definition
2170 is seen. But at end of compilation, do output code for them. */
2171 if (at_end || !DECL_DEFER_OUTPUT (decl))
2172 assemble_variable (decl, top_level, at_end, 0);
2174 #ifdef ASM_FINISH_DECLARE_OBJECT
2175 if (decl == last_assemble_variable_decl)
2177 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
2182 timevar_pop (TV_VARCONST);
2184 else if (DECL_REGISTER (decl) && asmspec != 0)
2186 if (decode_reg_name (asmspec) >= 0)
2188 SET_DECL_RTL (decl, NULL_RTX);
2189 make_decl_rtl (decl, asmspec);
2193 error ("invalid register name `%s' for register variable", asmspec);
2194 DECL_REGISTER (decl) = 0;
2199 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2200 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2201 && TREE_CODE (decl) == TYPE_DECL)
2203 timevar_push (TV_SYMOUT);
2204 dbxout_symbol (decl, 0);
2205 timevar_pop (TV_SYMOUT);
2208 #ifdef SDB_DEBUGGING_INFO
2209 else if (write_symbols == SDB_DEBUG && top_level
2210 && TREE_CODE (decl) == TYPE_DECL)
2212 timevar_push (TV_SYMOUT);
2213 sdbout_symbol (decl, 0);
2214 timevar_pop (TV_SYMOUT);
2217 #ifdef DWARF2_DEBUGGING_INFO
2218 else if ((write_symbols == DWARF2_DEBUG
2219 || write_symbols == VMS_AND_DWARF2_DEBUG)
2221 && TREE_CODE (decl) == TYPE_DECL)
2223 timevar_push (TV_SYMOUT);
2224 dwarf2out_decl (decl);
2225 timevar_pop (TV_SYMOUT);
2230 /* Called after finishing a record, union or enumeral type. */
2233 rest_of_type_compilation (
2234 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) \
2235 || defined (SDB_DEBUGGING_INFO) || defined (DWARF2_DEBUGGING_INFO)
2239 tree type ATTRIBUTE_UNUSED,
2240 int toplev ATTRIBUTE_UNUSED
2244 /* Avoid confusing the debug information machinery when there are
2246 if (errorcount != 0 || sorrycount != 0)
2249 timevar_push (TV_SYMOUT);
2250 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2251 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2252 dbxout_symbol (TYPE_STUB_DECL (type), !toplev);
2254 #ifdef SDB_DEBUGGING_INFO
2255 if (write_symbols == SDB_DEBUG)
2256 sdbout_symbol (TYPE_STUB_DECL (type), !toplev);
2258 #ifdef DWARF2_DEBUGGING_INFO
2259 if ((write_symbols == DWARF2_DEBUG
2260 || write_symbols == VMS_AND_DWARF2_DEBUG)
2262 dwarf2out_decl (TYPE_STUB_DECL (type));
2264 timevar_pop (TV_SYMOUT);
2267 /* Turn the RTL into assembly. */
2269 rest_of_handle_final (tree decl, rtx insns)
2271 timevar_push (TV_FINAL);
2276 /* Get the function's name, as described by its RTL. This may be
2277 different from the DECL_NAME name used in the source file. */
2279 x = DECL_RTL (decl);
2280 if (GET_CODE (x) != MEM)
2283 if (GET_CODE (x) != SYMBOL_REF)
2285 fnname = XSTR (x, 0);
2287 assemble_start_function (decl, fnname);
2288 final_start_function (insns, asm_out_file, optimize);
2289 final (insns, asm_out_file, optimize, 0);
2290 final_end_function ();
2292 #ifdef IA64_UNWIND_INFO
2293 /* ??? The IA-64 ".handlerdata" directive must be issued before
2294 the ".endp" directive that closes the procedure descriptor. */
2295 output_function_exception_table ();
2298 assemble_end_function (decl, fnname);
2300 #ifndef IA64_UNWIND_INFO
2301 /* Otherwise, it feels unclean to switch sections in the middle. */
2302 output_function_exception_table ();
2306 fflush (asm_out_file);
2308 /* Release all memory allocated by flow. */
2309 free_basic_block_vars (0);
2311 /* Release all memory held by regsets now. */
2312 regset_release_memory ();
2314 timevar_pop (TV_FINAL);
2320 /* Run delay slot optimization. */
2322 rest_of_handle_delay_slots (tree decl, rtx insns)
2324 timevar_push (TV_DBR_SCHED);
2325 open_dump_file (DFI_dbr, decl);
2327 dbr_schedule (insns, rtl_dump_file);
2329 close_dump_file (DFI_dbr, print_rtl, insns);
2330 timevar_pop (TV_DBR_SCHED);
2337 /* Convert register usage from flat register file usage to a stack
2340 rest_of_handle_stack_regs (tree decl, rtx insns)
2342 timevar_push (TV_REG_STACK);
2343 open_dump_file (DFI_stack, decl);
2345 if (reg_to_stack (insns, rtl_dump_file) && optimize)
2347 if (cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK
2348 | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0))
2349 && flag_reorder_blocks)
2351 reorder_basic_blocks ();
2352 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK);
2356 close_dump_file (DFI_stack, print_rtl_with_bb, insns);
2357 timevar_pop (TV_REG_STACK);
2364 /* Machine independent reorg pass. */
2366 rest_of_handle_machine_reorg (tree decl, rtx insns)
2368 timevar_push (TV_MACH_DEP);
2369 open_dump_file (DFI_mach, decl);
2371 (*targetm.machine_dependent_reorg) ();
2373 close_dump_file (DFI_mach, print_rtl, insns);
2374 timevar_pop (TV_MACH_DEP);
2380 /* Run new register allocator. Return TRUE if we must exit
2381 rest_of_compilation upon return. */
2383 rest_of_handle_new_regalloc (tree decl, rtx insns, int *rebuild_notes)
2387 delete_trivially_dead_insns (insns, max_reg_num ());
2390 timevar_pop (TV_LOCAL_ALLOC);
2391 if (dump_file[DFI_lreg].enabled)
2393 timevar_push (TV_DUMP);
2395 close_dump_file (DFI_lreg, NULL, NULL);
2396 timevar_pop (TV_DUMP);
2399 /* XXX clean up the whole mess to bring live info in shape again. */
2400 timevar_push (TV_GLOBAL_ALLOC);
2401 open_dump_file (DFI_greg, decl);
2403 build_insn_chain (insns);
2404 failure = reload (insns, 0);
2406 timevar_pop (TV_GLOBAL_ALLOC);
2408 if (dump_file[DFI_greg].enabled)
2410 timevar_push (TV_DUMP);
2412 dump_global_regs (rtl_dump_file);
2414 close_dump_file (DFI_greg, print_rtl_with_bb, insns);
2415 timevar_pop (TV_DUMP);
2421 reload_completed = 1;
2427 /* Run old register allocator. Return TRUE if we must exit
2428 rest_of_compilation upon return. */
2430 rest_of_handle_old_regalloc (tree decl, rtx insns, int *rebuild_notes)
2434 /* Allocate the reg_renumber array. */
2435 allocate_reg_info (max_regno, FALSE, TRUE);
2437 /* And the reg_equiv_memory_loc array. */
2438 reg_equiv_memory_loc = (rtx *) xcalloc (max_regno, sizeof (rtx));
2440 allocate_initial_values (reg_equiv_memory_loc);
2442 regclass (insns, max_reg_num (), rtl_dump_file);
2443 *rebuild_notes = local_alloc ();
2445 timevar_pop (TV_LOCAL_ALLOC);
2447 if (dump_file[DFI_lreg].enabled)
2449 timevar_push (TV_DUMP);
2451 dump_flow_info (rtl_dump_file);
2452 dump_local_alloc (rtl_dump_file);
2454 close_dump_file (DFI_lreg, print_rtl_with_bb, insns);
2455 timevar_pop (TV_DUMP);
2460 timevar_push (TV_GLOBAL_ALLOC);
2461 open_dump_file (DFI_greg, decl);
2463 /* If optimizing, allocate remaining pseudo-regs. Do the reload
2464 pass fixing up any insns that are invalid. */
2467 failure = global_alloc (rtl_dump_file);
2470 build_insn_chain (insns);
2471 failure = reload (insns, 0);
2474 timevar_pop (TV_GLOBAL_ALLOC);
2476 if (dump_file[DFI_greg].enabled)
2478 timevar_push (TV_DUMP);
2480 dump_global_regs (rtl_dump_file);
2482 close_dump_file (DFI_greg, print_rtl_with_bb, insns);
2483 timevar_pop (TV_DUMP);
2489 /* Run the regrename and cprop passes. */
2491 rest_of_handle_regrename (tree decl, rtx insns)
2493 timevar_push (TV_RENAME_REGISTERS);
2494 open_dump_file (DFI_rnreg, decl);
2496 if (flag_rename_registers)
2497 regrename_optimize ();
2498 if (flag_cprop_registers)
2499 copyprop_hardreg_forward ();
2501 close_dump_file (DFI_rnreg, print_rtl_with_bb, insns);
2502 timevar_pop (TV_RENAME_REGISTERS);
2505 /* Reorder basic blocks. */
2507 rest_of_handle_reorder_blocks (tree decl, rtx insns)
2509 timevar_push (TV_REORDER_BLOCKS);
2510 open_dump_file (DFI_bbro, decl);
2512 /* Last attempt to optimize CFG, as scheduling, peepholing and insn
2513 splitting possibly introduced more crossjumping opportunities. */
2514 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE
2515 | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0));
2517 if (flag_sched2_use_traces && flag_schedule_insns_after_reload)
2519 if (flag_reorder_blocks)
2520 reorder_basic_blocks ();
2521 if (flag_reorder_blocks
2522 || (flag_sched2_use_traces && flag_schedule_insns_after_reload))
2523 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
2525 close_dump_file (DFI_bbro, print_rtl_with_bb, insns);
2526 timevar_pop (TV_REORDER_BLOCKS);
2529 #ifdef INSN_SCHEDULING
2530 /* Run instruction scheduler. */
2532 rest_of_handle_sched (tree decl, rtx insns)
2534 timevar_push (TV_SCHED);
2536 /* Print function header into sched dump now
2537 because doing the sched analysis makes some of the dump. */
2538 if (optimize > 0 && flag_schedule_insns)
2540 open_dump_file (DFI_sched, decl);
2542 /* Do control and data sched analysis,
2543 and write some of the results to dump file. */
2545 schedule_insns (rtl_dump_file);
2547 close_dump_file (DFI_sched, print_rtl_with_bb, insns);
2549 timevar_pop (TV_SCHED);
2554 /* Run second scheduling pass after reload. */
2556 rest_of_handle_sched2 (tree decl, rtx insns)
2558 timevar_push (TV_SCHED2);
2559 open_dump_file (DFI_sched2, decl);
2561 /* Do control and data sched analysis again,
2562 and write some more of the results to dump file. */
2564 split_all_insns (1);
2566 if (flag_sched2_use_superblocks || flag_sched2_use_traces)
2568 schedule_ebbs (rtl_dump_file);
2569 /* No liveness updating code yet, but it should be easy to do.
2570 reg-stack recompute the liveness when needed for now. */
2571 count_or_remove_death_notes (NULL, 1);
2572 cleanup_cfg (CLEANUP_EXPENSIVE);
2575 schedule_insns (rtl_dump_file);
2577 close_dump_file (DFI_sched2, print_rtl_with_bb, insns);
2578 timevar_pop (TV_SCHED2);
2584 /* Register allocation pre-pass, to reduce number of moves necessary
2585 for two-address machines. */
2587 rest_of_handle_regmove (tree decl, rtx insns)
2589 timevar_push (TV_REGMOVE);
2590 open_dump_file (DFI_regmove, decl);
2592 regmove_optimize (insns, max_reg_num (), rtl_dump_file);
2594 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
2595 close_dump_file (DFI_regmove, print_rtl_with_bb, insns);
2596 timevar_pop (TV_REGMOVE);
2603 rest_of_handle_tracer (tree decl, rtx insns)
2605 timevar_push (TV_TRACER);
2606 open_dump_file (DFI_tracer, decl);
2608 dump_flow_info (rtl_dump_file);
2610 cleanup_cfg (CLEANUP_EXPENSIVE);
2611 reg_scan (insns, max_reg_num (), 0);
2612 close_dump_file (DFI_tracer, print_rtl_with_bb, get_insns ());
2613 timevar_pop (TV_TRACER);
2616 /* If-conversion and CFG cleanup. */
2618 rest_of_handle_if_conversion (tree decl, rtx insns)
2620 open_dump_file (DFI_ce1, decl);
2621 if (flag_if_conversion)
2623 timevar_push (TV_IFCVT);
2625 dump_flow_info (rtl_dump_file);
2626 cleanup_cfg (CLEANUP_EXPENSIVE);
2627 reg_scan (insns, max_reg_num (), 0);
2629 timevar_pop (TV_IFCVT);
2631 timevar_push (TV_JUMP);
2632 cleanup_cfg (CLEANUP_EXPENSIVE);
2633 reg_scan (insns, max_reg_num (), 0);
2634 timevar_pop (TV_JUMP);
2635 close_dump_file (DFI_ce1, print_rtl_with_bb, get_insns ());
2638 /* Rerun if-conversion, as combine may have simplified things enough
2639 to now meet sequence length restrictions. */
2641 rest_of_handle_if_after_combine (tree decl, rtx insns)
2643 timevar_push (TV_IFCVT);
2644 open_dump_file (DFI_ce2, decl);
2650 close_dump_file (DFI_ce2, print_rtl_with_bb, insns);
2651 timevar_pop (TV_IFCVT);
2654 /* Do branch profiling and static profile estimation passes. */
2656 rest_of_handle_branch_prob (tree decl, rtx insns)
2660 timevar_push (TV_BRANCH_PROB);
2661 open_dump_file (DFI_bp, decl);
2662 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
2665 /* Discover and record the loop depth at the head of each basic
2666 block. The loop infrastructure does the real job for us. */
2667 flow_loops_find (&loops, LOOP_TREE);
2670 flow_loops_dump (&loops, rtl_dump_file, NULL, 0);
2672 /* Estimate using heuristics if no profiling info is available. */
2673 if (flag_guess_branch_prob)
2674 estimate_probability (&loops);
2676 flow_loops_free (&loops);
2677 close_dump_file (DFI_bp, print_rtl_with_bb, insns);
2678 timevar_pop (TV_BRANCH_PROB);
2681 /* Do control and data flow analysis; write some of the results to the
2684 rest_of_handle_cfg (tree decl, rtx insns)
2686 open_dump_file (DFI_cfg, decl);
2688 dump_flow_info (rtl_dump_file);
2690 cleanup_cfg (CLEANUP_EXPENSIVE
2691 | (flag_thread_jumps ? CLEANUP_THREADING : 0));
2693 /* It may make more sense to mark constant functions after dead code is
2694 eliminated by life_analysis, but we need to do it early, as -fprofile-arcs
2695 may insert code making function non-constant, but we still must consider
2696 it as constant, otherwise -fbranch-probabilities will not read data back.
2698 life_analysis rarely eliminates modification of external memory.
2701 mark_constant_function ();
2703 close_dump_file (DFI_cfg, print_rtl_with_bb, insns);
2706 /* Purge addressofs. */
2708 rest_of_handle_addresof (tree decl, rtx insns)
2710 open_dump_file (DFI_addressof, decl);
2712 purge_addressof (insns);
2714 purge_all_dead_edges (0);
2715 reg_scan (insns, max_reg_num (), 1);
2717 close_dump_file (DFI_addressof, print_rtl, insns);
2720 /* We may have potential sibling or tail recursion sites. Select one
2721 (of possibly multiple) methods of performing the call. */
2723 rest_of_handle_sibling_calls (rtx insns)
2726 optimize_sibling_and_tail_recursive_calls ();
2728 /* Recompute the CFG as sibling optimization clobbers it randomly. */
2729 free_bb_for_insn ();
2730 find_exception_handler_labels ();
2731 rebuild_jump_labels (insns);
2732 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2734 /* There is pass ordering problem - we must lower NOTE_INSN_PREDICTION
2735 notes before simplifying cfg and we must do lowering after sibcall
2736 that unhides parts of RTL chain and cleans up the CFG.
2738 Until sibcall is replaced by tree-level optimizer, lets just
2739 sweep away the NOTE_INSN_PREDICTION notes that leaked out. */
2740 for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
2741 if (GET_CODE (insn) == NOTE
2742 && NOTE_LINE_NUMBER (insn) == NOTE_INSN_PREDICTION)
2745 close_dump_file (DFI_sibling, print_rtl, get_insns ());
2748 /* Perform jump bypassing and control flow optimizations. */
2750 rest_of_handle_jump_bypass (tree decl, rtx insns)
2752 timevar_push (TV_BYPASS);
2753 open_dump_file (DFI_bypass, decl);
2755 cleanup_cfg (CLEANUP_EXPENSIVE);
2757 if (bypass_jumps (rtl_dump_file))
2759 rebuild_jump_labels (insns);
2760 cleanup_cfg (CLEANUP_EXPENSIVE);
2761 delete_trivially_dead_insns (insns, max_reg_num ());
2764 close_dump_file (DFI_bypass, print_rtl_with_bb, insns);
2765 timevar_pop (TV_BYPASS);
2769 #ifdef ENABLE_CHECKING
2770 verify_flow_info ();
2774 /* Handle inlining of functions in rest_of_compilation. Return TRUE
2775 if we must exit rest_of_compilation upon return. */
2777 rest_of_handle_inlining (tree decl)
2784 /* If we are reconsidering an inline function at the end of
2785 compilation, skip the stuff for making it inline. */
2786 if (DECL_SAVED_INSNS (decl) != 0)
2789 /* If this is nested inside an inlined external function, pretend
2790 it was only declared. Since we cannot inline such functions,
2791 generating code for this one is not only not necessary but will
2792 confuse some debugging output writers. */
2793 for (parent = DECL_CONTEXT (current_function_decl);
2794 parent != NULL_TREE;
2795 parent = get_containing_scope (parent))
2796 if (TREE_CODE (parent) == FUNCTION_DECL
2797 && DECL_INLINE (parent) && DECL_EXTERNAL (parent))
2799 DECL_INITIAL (decl) = 0;
2802 else if (TYPE_P (parent))
2803 /* A function in a local class should be treated normally. */
2806 /* If requested, consider whether to make this function inline. */
2807 if ((DECL_INLINE (decl) && !flag_no_inline)
2808 || flag_inline_functions)
2810 timevar_push (TV_INTEGRATION);
2811 lose = function_cannot_inline_p (decl);
2812 timevar_pop (TV_INTEGRATION);
2813 if (lose || ! optimize)
2815 if (warn_inline && DECL_INLINE (decl))
2816 warning_with_decl (decl, lose);
2817 DECL_ABSTRACT_ORIGIN (decl) = 0;
2818 /* Don't really compile an extern inline function.
2819 If we can't make it inline, pretend
2820 it was only declared. */
2821 if (DECL_EXTERNAL (decl))
2823 DECL_INITIAL (decl) = 0;
2828 /* ??? Note that we used to just make it look like if
2829 the "inline" keyword was specified when we decide
2830 to inline it (because of -finline-functions).
2831 garloff@suse.de, 2002-04-24: Add another flag to
2832 actually record this piece of information. */
2833 if (!DECL_INLINE (decl))
2834 DID_INLINE_FUNC (decl) = 1;
2835 inlinable = DECL_INLINE (decl) = 1;
2839 insns = get_insns ();
2841 /* Dump the rtl code if we are dumping rtl. */
2843 if (open_dump_file (DFI_rtl, decl))
2845 if (DECL_SAVED_INSNS (decl))
2846 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2847 close_dump_file (DFI_rtl, print_rtl, insns);
2850 /* Convert from NOTE_INSN_EH_REGION style notes, and do other
2851 sorts of eh initialization. Delay this until after the
2852 initial rtl dump so that we can see the original nesting. */
2853 convert_from_eh_region_ranges ();
2855 /* If function is inline, and we don't yet know whether to
2856 compile it by itself, defer decision till end of compilation.
2857 wrapup_global_declarations will (indirectly) call
2858 rest_of_compilation again for those functions that need to
2859 be output. Also defer those functions that we are supposed
2863 || (DECL_INLINE (decl)
2864 && flag_inline_functions
2865 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2866 && ! TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))
2867 && ! flag_keep_inline_functions)
2868 || DECL_EXTERNAL (decl))))
2869 DECL_DEFER_OUTPUT (decl) = 1;
2871 if (DECL_INLINE (decl))
2872 /* DWARF wants separate debugging info for abstract and
2873 concrete instances of all inline functions, including those
2874 declared inline but not inlined, and those inlined even
2875 though they weren't declared inline. Conveniently, that's
2876 what DECL_INLINE means at this point. */
2877 (*debug_hooks->deferred_inline_function) (decl);
2879 if (DECL_DEFER_OUTPUT (decl))
2881 /* If -Wreturn-type, we have to do a bit of compilation. We just
2882 want to call cleanup the cfg to figure out whether or not we can
2883 fall off the end of the function; we do the minimum amount of
2884 work necessary to make that safe. */
2885 if (warn_return_type)
2887 int saved_optimize = optimize;
2890 rebuild_jump_labels (insns);
2891 find_exception_handler_labels ();
2892 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2893 cleanup_cfg (CLEANUP_PRE_SIBCALL | CLEANUP_PRE_LOOP);
2894 optimize = saved_optimize;
2896 /* CFG is no longer maintained up-to-date. */
2897 free_bb_for_insn ();
2900 set_nothrow_function_flags ();
2901 if (current_function_nothrow)
2902 /* Now we know that this can't throw; set the flag for the benefit
2903 of other functions later in this translation unit. */
2904 TREE_NOTHROW (current_function_decl) = 1;
2906 timevar_push (TV_INTEGRATION);
2907 save_for_inline (decl);
2908 timevar_pop (TV_INTEGRATION);
2909 DECL_SAVED_INSNS (decl)->inlinable = inlinable;
2913 /* If specified extern inline but we aren't inlining it, we are
2914 done. This goes for anything that gets here with DECL_EXTERNAL
2915 set, not just things with DECL_INLINE. */
2916 return (bool) DECL_EXTERNAL (decl);
2919 /* Rest of compilation helper to convert the rtl to SSA form. */
2921 rest_of_handle_ssa (tree decl, rtx insns)
2923 timevar_push (TV_TO_SSA);
2924 open_dump_file (DFI_ssa, decl);
2926 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2929 close_dump_file (DFI_ssa, print_rtl_with_bb, insns);
2930 timevar_pop (TV_TO_SSA);
2932 /* Perform sparse conditional constant propagation, if requested. */
2935 timevar_push (TV_SSA_CCP);
2936 open_dump_file (DFI_ssa_ccp, decl);
2940 close_dump_file (DFI_ssa_ccp, print_rtl_with_bb, get_insns ());
2941 timevar_pop (TV_SSA_CCP);
2944 /* It would be useful to cleanup the CFG at this point, but block
2945 merging and possibly other transformations might leave a PHI
2946 node in the middle of a basic block, which is a strict no-no. */
2948 /* The SSA implementation uses basic block numbers in its phi
2949 nodes. Thus, changing the control-flow graph or the basic
2950 blocks, e.g., calling find_basic_blocks () or cleanup_cfg (),
2951 may cause problems. */
2955 /* Remove dead code. */
2957 timevar_push (TV_SSA_DCE);
2958 open_dump_file (DFI_ssa_dce, decl);
2960 insns = get_insns ();
2961 ssa_eliminate_dead_code ();
2963 close_dump_file (DFI_ssa_dce, print_rtl_with_bb, insns);
2964 timevar_pop (TV_SSA_DCE);
2967 /* Convert from SSA form. */
2969 timevar_push (TV_FROM_SSA);
2970 open_dump_file (DFI_ussa, decl);
2972 convert_from_ssa ();
2973 /* New registers have been created. Rescan their usage. */
2974 reg_scan (insns, max_reg_num (), 1);
2976 close_dump_file (DFI_ussa, print_rtl_with_bb, insns);
2977 timevar_pop (TV_FROM_SSA);
2984 /* Try to identify useless null pointer tests and delete them. */
2986 rest_of_handle_null_pointer (tree decl, rtx insns)
2988 open_dump_file (DFI_null, decl);
2990 dump_flow_info (rtl_dump_file);
2992 if (delete_null_pointer_checks (insns))
2993 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2995 close_dump_file (DFI_null, print_rtl_with_bb, insns);
2998 /* Try combining insns through substitution. */
3000 rest_of_handle_combine (tree decl, rtx insns)
3002 int rebuild_jump_labels_after_combine = 0;
3004 timevar_push (TV_COMBINE);
3005 open_dump_file (DFI_combine, decl);
3007 rebuild_jump_labels_after_combine
3008 = combine_instructions (insns, max_reg_num ());
3010 /* Combining insns may have turned an indirect jump into a
3011 direct jump. Rebuild the JUMP_LABEL fields of jumping
3013 if (rebuild_jump_labels_after_combine)
3015 timevar_push (TV_JUMP);
3016 rebuild_jump_labels (insns);
3017 timevar_pop (TV_JUMP);
3019 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
3022 close_dump_file (DFI_combine, print_rtl_with_bb, insns);
3023 timevar_pop (TV_COMBINE);
3028 /* Perform life analysis. */
3030 rest_of_handle_life (tree decl, rtx insns)
3032 open_dump_file (DFI_life, decl);
3035 #ifdef ENABLE_CHECKING
3036 verify_flow_info ();
3038 life_analysis (insns, rtl_dump_file, PROP_FINAL);
3040 cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0) | CLEANUP_UPDATE_LIFE
3041 | (flag_thread_jumps ? CLEANUP_THREADING : 0));
3042 timevar_pop (TV_FLOW);
3044 if (warn_uninitialized)
3046 uninitialized_vars_warning (DECL_INITIAL (decl));
3048 setjmp_args_warning ();
3053 if (!flag_new_regalloc && initialize_uninitialized_subregs ())
3055 /* Insns were inserted, and possibly pseudos created, so
3056 things might look a bit different. */
3057 insns = get_insns ();
3058 allocate_reg_life_data ();
3059 update_life_info (NULL, UPDATE_LIFE_GLOBAL_RM_NOTES,
3060 PROP_LOG_LINKS | PROP_REG_INFO | PROP_DEATH_NOTES);
3066 close_dump_file (DFI_life, print_rtl_with_bb, insns);
3071 /* Perform common subexpression elimination. Nonzero value from
3072 `cse_main' means that jumps were simplified and some code may now
3073 be unreachable, so do jump optimization again. */
3075 rest_of_handle_cse (tree decl, rtx insns)
3079 open_dump_file (DFI_cse, decl);
3081 dump_flow_info (rtl_dump_file);
3082 timevar_push (TV_CSE);
3084 reg_scan (insns, max_reg_num (), 1);
3086 tem = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
3088 rebuild_jump_labels (insns);
3089 purge_all_dead_edges (0);
3091 delete_trivially_dead_insns (insns, max_reg_num ());
3093 /* If we are not running more CSE passes, then we are no longer
3094 expecting CSE to be run. But always rerun it in a cheap mode. */
3095 cse_not_expected = !flag_rerun_cse_after_loop && !flag_gcse;
3097 if (tem || optimize > 1)
3098 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
3099 /* Try to identify useless null pointer tests and delete them. */
3100 if (flag_delete_null_pointer_checks)
3102 timevar_push (TV_JUMP);
3104 if (delete_null_pointer_checks (insns))
3105 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
3106 timevar_pop (TV_JUMP);
3109 /* The second pass of jump optimization is likely to have
3110 removed a bunch more instructions. */
3111 renumber_insns (rtl_dump_file);
3113 timevar_pop (TV_CSE);
3114 close_dump_file (DFI_cse, print_rtl_with_bb, insns);
3117 /* Run second CSE pass after loop optimizations. */
3119 rest_of_handle_cse2 (tree decl, rtx insns)
3123 timevar_push (TV_CSE2);
3124 open_dump_file (DFI_cse2, decl);
3126 dump_flow_info (rtl_dump_file);
3127 /* CFG is no longer maintained up-to-date. */
3128 tem = cse_main (insns, max_reg_num (), 1, rtl_dump_file);
3129 purge_all_dead_edges (0);
3130 delete_trivially_dead_insns (insns, max_reg_num ());
3134 timevar_push (TV_JUMP);
3135 rebuild_jump_labels (insns);
3136 cleanup_cfg (CLEANUP_EXPENSIVE);
3137 timevar_pop (TV_JUMP);
3139 reg_scan (insns, max_reg_num (), 0);
3140 close_dump_file (DFI_cse2, print_rtl_with_bb, insns);
3142 timevar_pop (TV_CSE2);
3145 /* Perform global cse. */
3147 rest_of_handle_gcse (tree decl, rtx insns)
3149 int save_csb, save_cfj;
3152 timevar_push (TV_GCSE);
3153 open_dump_file (DFI_gcse, decl);
3155 tem = gcse_main (insns, rtl_dump_file);
3156 rebuild_jump_labels (insns);
3157 delete_trivially_dead_insns (insns, max_reg_num ());
3159 save_csb = flag_cse_skip_blocks;
3160 save_cfj = flag_cse_follow_jumps;
3161 flag_cse_skip_blocks = flag_cse_follow_jumps = 0;
3163 /* Instantiate any remaining CONSTANT_P_RTX nodes. */
3164 if (current_function_calls_constant_p)
3165 purge_builtin_constant_p ();
3167 /* If -fexpensive-optimizations, re-run CSE to clean up things done
3169 if (flag_expensive_optimizations)
3171 timevar_push (TV_CSE);
3172 reg_scan (insns, max_reg_num (), 1);
3173 tem2 = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
3174 purge_all_dead_edges (0);
3175 delete_trivially_dead_insns (insns, max_reg_num ());
3176 timevar_pop (TV_CSE);
3177 cse_not_expected = !flag_rerun_cse_after_loop;
3180 /* If gcse or cse altered any jumps, rerun jump optimizations to clean
3181 things up. Then possibly re-run CSE again. */
3185 timevar_push (TV_JUMP);
3186 rebuild_jump_labels (insns);
3187 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
3188 timevar_pop (TV_JUMP);
3190 if (flag_expensive_optimizations)
3192 timevar_push (TV_CSE);
3193 reg_scan (insns, max_reg_num (), 1);
3194 tem2 = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
3195 purge_all_dead_edges (0);
3196 delete_trivially_dead_insns (insns, max_reg_num ());
3197 timevar_pop (TV_CSE);
3201 close_dump_file (DFI_gcse, print_rtl_with_bb, insns);
3202 timevar_pop (TV_GCSE);
3205 flag_cse_skip_blocks = save_csb;
3206 flag_cse_follow_jumps = save_cfj;
3207 #ifdef ENABLE_CHECKING
3208 verify_flow_info ();
3212 /* Move constant computations out of loops. */
3214 rest_of_handle_loop_optimize (tree decl, rtx insns)
3216 int do_unroll, do_prefetch;
3218 timevar_push (TV_LOOP);
3219 delete_dead_jumptables ();
3220 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
3221 open_dump_file (DFI_loop, decl);
3223 /* CFG is no longer maintained up-to-date. */
3224 free_bb_for_insn ();
3226 if (flag_unroll_loops)
3227 do_unroll = 0; /* Having two unrollers is useless. */
3229 do_unroll = flag_old_unroll_loops ? LOOP_UNROLL : LOOP_AUTO_UNROLL;
3230 do_prefetch = flag_prefetch_loop_arrays ? LOOP_PREFETCH : 0;
3232 if (flag_rerun_loop_opt)
3234 cleanup_barriers ();
3236 /* We only want to perform unrolling once. */
3237 loop_optimize (insns, rtl_dump_file, do_unroll);
3240 /* The first call to loop_optimize makes some instructions
3241 trivially dead. We delete those instructions now in the
3242 hope that doing so will make the heuristics in loop work
3243 better and possibly speed up compilation. */
3244 delete_trivially_dead_insns (insns, max_reg_num ());
3246 /* The regscan pass is currently necessary as the alias
3247 analysis code depends on this information. */
3248 reg_scan (insns, max_reg_num (), 1);
3250 cleanup_barriers ();
3251 loop_optimize (insns, rtl_dump_file, do_unroll | LOOP_BCT | do_prefetch);
3253 /* Loop can create trivially dead instructions. */
3254 delete_trivially_dead_insns (insns, max_reg_num ());
3255 close_dump_file (DFI_loop, print_rtl, insns);
3256 timevar_pop (TV_LOOP);
3257 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3262 /* Perform loop optimalizations. It might be better to do them a bit
3263 sooner, but we want the profile feedback to work more
3266 rest_of_handle_loop2 (tree decl, rtx insns)
3268 struct loops *loops;
3269 timevar_push (TV_LOOP);
3270 open_dump_file (DFI_loop2, decl);
3272 dump_flow_info (rtl_dump_file);
3274 loops = loop_optimizer_init (rtl_dump_file);
3278 /* The optimalizations: */
3279 if (flag_unswitch_loops)
3280 unswitch_loops (loops);
3282 if (flag_peel_loops || flag_unroll_loops)
3283 unroll_and_peel_loops (loops,
3284 (flag_peel_loops ? UAP_PEEL : 0) |
3285 (flag_unroll_loops ? UAP_UNROLL : 0) |
3286 (flag_unroll_all_loops ? UAP_UNROLL_ALL : 0));
3288 loop_optimizer_finalize (loops, rtl_dump_file);
3291 cleanup_cfg (CLEANUP_EXPENSIVE);
3292 delete_trivially_dead_insns (insns, max_reg_num ());
3293 reg_scan (insns, max_reg_num (), 0);
3295 dump_flow_info (rtl_dump_file);
3296 close_dump_file (DFI_loop2, print_rtl_with_bb, get_insns ());
3297 timevar_pop (TV_LOOP);
3301 /* This is called from finish_function (within langhooks.parse_file)
3302 after each top-level definition is parsed.
3303 It is supposed to compile that function or variable
3304 and output the assembler code for it.
3305 After we return, the tree storage is freed. */
3308 rest_of_compilation (tree decl)
3311 int rebuild_label_notes_after_reload;
3313 timevar_push (TV_REST_OF_COMPILATION);
3315 /* Register rtl specific functions for cfg. */
3316 rtl_register_cfg_hooks ();
3318 /* Now that we're out of the frontend, we shouldn't have any more
3319 CONCATs anywhere. */
3320 generating_concat_p = 0;
3322 /* When processing delayed functions, prepare_function_start() won't
3323 have been run to re-initialize it. */
3324 cse_not_expected = ! optimize;
3326 /* First, make sure that NOTE_BLOCK is set correctly for each
3327 NOTE_INSN_BLOCK_BEG/NOTE_INSN_BLOCK_END note. */
3328 if (!cfun->x_whole_function_mode_p)
3331 /* In function-at-a-time mode, we do not attempt to keep the BLOCK
3332 tree in sensible shape. So, we just recalculate it here. */
3333 if (cfun->x_whole_function_mode_p)
3338 if (rest_of_handle_inlining (decl))
3339 goto exit_rest_of_compilation;
3341 /* If we're emitting a nested function, make sure its parent gets
3342 emitted as well. Doing otherwise confuses debug info. */
3345 for (parent = DECL_CONTEXT (current_function_decl);
3346 parent != NULL_TREE;
3347 parent = get_containing_scope (parent))
3348 if (TREE_CODE (parent) == FUNCTION_DECL)
3349 TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (parent)) = 1;
3352 /* We are now committed to emitting code for this function. Do any
3353 preparation, such as emitting abstract debug info for the inline
3354 before it gets mangled by optimization. */
3355 if (DECL_INLINE (decl))
3356 (*debug_hooks->outlining_inline_function) (decl);
3358 /* Remove any notes we don't need. That will make iterating
3359 over the instruction sequence faster, and allow the garbage
3360 collector to reclaim the memory used by the notes. */
3361 remove_unnecessary_notes ();
3366 /* Initialize some variables used by the optimizers. */
3367 init_function_for_compilation ();
3369 if (! DECL_DEFER_OUTPUT (decl))
3370 TREE_ASM_WRITTEN (decl) = 1;
3372 /* Now that integrate will no longer see our rtl, we need not
3373 distinguish between the return value of this function and the
3374 return value of called functions. Also, we can remove all SETs
3375 of subregs of hard registers; they are only here because of
3376 integrate. Also, we can now initialize pseudos intended to
3377 carry magic hard reg data throughout the function. */
3378 rtx_equal_function_value_matters = 0;
3379 purge_hard_subreg_sets (get_insns ());
3381 /* Early return if there were errors. We can run afoul of our
3382 consistency checks, and there's not really much point in fixing them.
3383 Don't return yet if -Wreturn-type; we need to do cleanup_cfg. */
3384 if (((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
3385 || errorcount || sorrycount)
3386 goto exit_rest_of_compilation;
3388 timevar_push (TV_JUMP);
3389 open_dump_file (DFI_sibling, decl);
3390 insns = get_insns ();
3391 rebuild_jump_labels (insns);
3392 find_exception_handler_labels ();
3393 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3395 delete_unreachable_blocks ();
3397 /* We have to issue these warnings now already, because CFG cleanups
3398 further down may destroy the required information. */
3399 check_function_return_warnings ();
3401 /* Turn NOTE_INSN_PREDICTIONs into branch predictions. */
3402 if (flag_guess_branch_prob)
3404 timevar_push (TV_BRANCH_PROB);
3405 note_prediction_to_br_prob ();
3406 timevar_pop (TV_BRANCH_PROB);
3409 if (flag_optimize_sibling_calls)
3410 rest_of_handle_sibling_calls (insns);
3412 timevar_pop (TV_JUMP);
3414 insn_locators_initialize ();
3415 /* Complete generation of exception handling code. */
3418 timevar_push (TV_JUMP);
3419 open_dump_file (DFI_eh, decl);
3421 finish_eh_generation ();
3423 close_dump_file (DFI_eh, print_rtl, get_insns ());
3424 timevar_pop (TV_JUMP);
3427 /* Delay emitting hard_reg_initial_value sets until after EH landing pad
3428 generation, which might create new sets. */
3429 emit_initial_value_sets ();
3432 /* If we are doing position-independent code generation, now
3433 is the time to output special prologues and epilogues.
3434 We do not want to do this earlier, because it just clutters
3435 up inline functions with meaningless insns. */
3440 insns = get_insns ();
3442 /* Copy any shared structure that should not be shared. */
3443 unshare_all_rtl (current_function_decl, insns);
3445 #ifdef SETJMP_VIA_SAVE_AREA
3446 /* This must be performed before virtual register instantiation.
3447 Please be aware the everything in the compiler that can look
3448 at the RTL up to this point must understand that REG_SAVE_AREA
3449 is just like a use of the REG contained inside. */
3450 if (current_function_calls_alloca)
3451 optimize_save_area_alloca (insns);
3454 /* Instantiate all virtual registers. */
3455 instantiate_virtual_regs (current_function_decl, insns);
3457 open_dump_file (DFI_jump, decl);
3459 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
3460 are initialized and to compute whether control can drop off the end
3463 timevar_push (TV_JUMP);
3464 /* Turn NOTE_INSN_EXPECTED_VALUE into REG_BR_PROB. Do this
3465 before jump optimization switches branch directions. */
3466 if (flag_guess_branch_prob)
3467 expected_value_to_br_prob ();
3469 reg_scan (insns, max_reg_num (), 0);
3470 rebuild_jump_labels (insns);
3471 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3472 delete_trivially_dead_insns (insns, max_reg_num ());
3474 dump_flow_info (rtl_dump_file);
3475 cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0) | CLEANUP_PRE_LOOP
3476 | (flag_thread_jumps ? CLEANUP_THREADING : 0));
3480 free_bb_for_insn ();
3481 copy_loop_headers (insns);
3482 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3484 purge_line_number_notes (insns);
3486 timevar_pop (TV_JUMP);
3487 close_dump_file (DFI_jump, print_rtl, insns);
3489 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
3490 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
3491 goto exit_rest_of_compilation;
3493 /* Long term, this should probably move before the jump optimizer too,
3494 but I didn't want to disturb the rtl_dump_and_exit and related
3495 stuff at this time. */
3496 if (optimize > 0 && flag_ssa)
3497 insns = rest_of_handle_ssa (decl, insns);
3499 timevar_push (TV_JUMP);
3502 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
3504 if (flag_delete_null_pointer_checks)
3505 rest_of_handle_null_pointer (decl, insns);
3507 /* Jump optimization, and the removal of NULL pointer checks, may
3508 have reduced the number of instructions substantially. CSE, and
3509 future passes, allocate arrays whose dimensions involve the
3510 maximum instruction UID, so if we can reduce the maximum UID
3511 we'll save big on memory. */
3512 renumber_insns (rtl_dump_file);
3513 timevar_pop (TV_JUMP);
3515 close_dump_file (DFI_jump, print_rtl_with_bb, insns);
3520 rest_of_handle_cse (decl, insns);
3522 rest_of_handle_addresof (decl, insns);
3529 rest_of_handle_gcse (decl, insns);
3531 if (flag_loop_optimize)
3532 rest_of_handle_loop_optimize (decl, insns);
3535 rest_of_handle_jump_bypass (decl, insns);
3538 timevar_push (TV_FLOW);
3540 rest_of_handle_cfg (decl, insns);
3543 || profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
3544 rest_of_handle_branch_prob (decl, insns);
3547 rest_of_handle_if_conversion (decl, insns);
3550 rest_of_handle_tracer (decl, insns);
3553 && (flag_unswitch_loops
3555 || flag_unroll_loops))
3556 rest_of_handle_loop2 (decl, insns);
3558 if (flag_rerun_cse_after_loop)
3559 rest_of_handle_cse2 (decl, insns);
3561 cse_not_expected = 1;
3563 rest_of_handle_life (decl, insns);
3566 rest_of_handle_combine (decl, insns);
3568 if (flag_if_conversion)
3569 rest_of_handle_if_after_combine (decl, insns);
3571 if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
3572 rest_of_handle_regmove (decl, insns);
3574 /* Do unconditional splitting before register allocation to allow machine
3575 description to add extra information not needed previously. */
3576 split_all_insns (1);
3578 #ifdef OPTIMIZE_MODE_SWITCHING
3579 timevar_push (TV_MODE_SWITCH);
3582 optimize_mode_switching (NULL);
3585 timevar_pop (TV_MODE_SWITCH);
3588 /* Any of the several passes since flow1 will have munged register
3589 lifetime data a bit. We need it to be up to date for scheduling
3590 (see handling of reg_known_equiv in init_alias_analysis). */
3591 recompute_reg_usage (insns, !optimize_size);
3593 #ifdef INSN_SCHEDULING
3594 rest_of_handle_sched (decl, insns);
3597 /* Determine if the current function is a leaf before running reload
3598 since this can impact optimizations done by the prologue and
3599 epilogue thus changing register elimination offsets. */
3600 current_function_is_leaf = leaf_function_p ();
3602 timevar_push (TV_LOCAL_ALLOC);
3603 open_dump_file (DFI_lreg, decl);
3605 if (flag_new_regalloc)
3607 if (rest_of_handle_new_regalloc (decl, insns,
3608 &rebuild_label_notes_after_reload))
3609 goto exit_rest_of_compilation;
3613 if (rest_of_handle_old_regalloc (decl, insns,
3614 &rebuild_label_notes_after_reload))
3615 goto exit_rest_of_compilation;
3620 open_dump_file (DFI_postreload, decl);
3622 /* Do a very simple CSE pass over just the hard registers. */
3625 timevar_push (TV_RELOAD_CSE_REGS);
3626 reload_cse_regs (insns);
3627 timevar_pop (TV_RELOAD_CSE_REGS);
3630 /* Register allocation and reloading may have turned an indirect jump into
3631 a direct jump. If so, we must rebuild the JUMP_LABEL fields of
3632 jumping instructions. */
3633 if (rebuild_label_notes_after_reload)
3635 timevar_push (TV_JUMP);
3637 rebuild_jump_labels (insns);
3638 purge_all_dead_edges (0);
3640 timevar_pop (TV_JUMP);
3643 close_dump_file (DFI_postreload, print_rtl_with_bb, insns);
3645 /* Re-create the death notes which were deleted during reload. */
3646 timevar_push (TV_FLOW2);
3647 open_dump_file (DFI_flow2, decl);
3649 #ifdef ENABLE_CHECKING
3650 verify_flow_info ();
3653 /* If optimizing, then go ahead and split insns now. */
3657 split_all_insns (0);
3659 if (flag_branch_target_load_optimize)
3661 open_dump_file (DFI_branch_target_load, decl);
3663 branch_target_load_optimize (insns, false);
3665 close_dump_file (DFI_branch_target_load, print_rtl_with_bb, insns);
3671 cleanup_cfg (CLEANUP_EXPENSIVE);
3673 /* On some machines, the prologue and epilogue code, or parts thereof,
3674 can be represented as RTL. Doing so lets us schedule insns between
3675 it and the rest of the code and also allows delayed branch
3676 scheduling to operate in the epilogue. */
3677 thread_prologue_and_epilogue_insns (insns);
3678 epilogue_completed = 1;
3682 life_analysis (insns, rtl_dump_file, PROP_FINAL);
3683 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE
3684 | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0));
3686 /* This is kind of a heuristic. We need to run combine_stack_adjustments
3687 even for machines with possibly nonzero RETURN_POPS_ARGS
3688 and ACCUMULATE_OUTGOING_ARGS. We expect that only ports having
3689 push instructions will have popping returns. */
3690 #ifndef PUSH_ROUNDING
3691 if (!ACCUMULATE_OUTGOING_ARGS)
3693 combine_stack_adjustments ();
3698 flow2_completed = 1;
3700 close_dump_file (DFI_flow2, print_rtl_with_bb, insns);
3701 timevar_pop (TV_FLOW2);
3703 #ifdef HAVE_peephole2
3704 if (optimize > 0 && flag_peephole2)
3706 timevar_push (TV_PEEPHOLE2);
3707 open_dump_file (DFI_peephole2, decl);
3709 peephole2_optimize (rtl_dump_file);
3711 close_dump_file (DFI_peephole2, print_rtl_with_bb, insns);
3712 timevar_pop (TV_PEEPHOLE2);
3718 if (flag_rename_registers || flag_cprop_registers)
3719 rest_of_handle_regrename (decl, insns);
3721 rest_of_handle_reorder_blocks (decl, insns);
3724 if (flag_if_conversion2)
3726 timevar_push (TV_IFCVT2);
3727 open_dump_file (DFI_ce3, decl);
3731 close_dump_file (DFI_ce3, print_rtl_with_bb, insns);
3732 timevar_pop (TV_IFCVT2);
3735 if (flag_branch_target_load_optimize2)
3737 /* Leave this a warning for now so that it is possible to experiment
3738 with running this pass twice. In 3.6, we should either make this
3739 an error, or use separate dump files. */
3740 if (flag_branch_target_load_optimize)
3741 warning ("branch target register load optimization is not intended "
3744 open_dump_file (DFI_branch_target_load, decl);
3746 branch_target_load_optimize (insns, true);
3748 close_dump_file (DFI_branch_target_load, print_rtl_with_bb, insns);
3753 #ifdef INSN_SCHEDULING
3754 if (optimize > 0 && flag_schedule_insns_after_reload)
3755 rest_of_handle_sched2 (decl, insns);
3758 #ifdef LEAF_REGISTERS
3759 current_function_uses_only_leaf_regs
3760 = optimize > 0 && only_leaf_regs_used () && leaf_function_p ();
3764 rest_of_handle_stack_regs (decl, insns);
3767 compute_alignments ();
3769 /* CFG is no longer maintained up-to-date. */
3770 free_bb_for_insn ();
3772 if (targetm.machine_dependent_reorg != 0)
3773 rest_of_handle_machine_reorg (decl, insns);
3775 purge_line_number_notes (insns);
3776 cleanup_barriers ();
3779 if (optimize > 0 && flag_delayed_branch)
3780 rest_of_handle_delay_slots (decl, insns);
3783 #if defined (HAVE_ATTR_length) && !defined (STACK_REGS)
3784 timevar_push (TV_SHORTEN_BRANCH);
3785 split_all_insns_noflow ();
3786 timevar_pop (TV_SHORTEN_BRANCH);
3789 convert_to_eh_region_ranges ();
3791 /* Shorten branches. */
3792 timevar_push (TV_SHORTEN_BRANCH);
3793 shorten_branches (get_insns ());
3794 timevar_pop (TV_SHORTEN_BRANCH);
3796 set_nothrow_function_flags ();
3797 if (current_function_nothrow)
3798 /* Now we know that this can't throw; set the flag for the benefit
3799 of other functions later in this translation unit. */
3800 TREE_NOTHROW (current_function_decl) = 1;
3802 rest_of_handle_final (decl, insns);
3804 /* Write DBX symbols if requested. */
3806 /* Note that for those inline functions where we don't initially
3807 know for certain that we will be generating an out-of-line copy,
3808 the first invocation of this routine (rest_of_compilation) will
3809 skip over this code by doing a `goto exit_rest_of_compilation;'.
3810 Later on, wrapup_global_declarations will (indirectly) call
3811 rest_of_compilation again for those inline functions that need
3812 to have out-of-line copies generated. During that call, we
3813 *will* be routed past here. */
3815 timevar_push (TV_SYMOUT);
3816 (*debug_hooks->function_decl) (decl);
3817 timevar_pop (TV_SYMOUT);
3819 exit_rest_of_compilation:
3821 coverage_end_function ();
3823 /* In case the function was not output,
3824 don't leave any temporary anonymous types
3825 queued up for sdb output. */
3826 #ifdef SDB_DEBUGGING_INFO
3827 if (write_symbols == SDB_DEBUG)
3828 sdbout_types (NULL_TREE);
3831 reload_completed = 0;
3832 epilogue_completed = 0;
3833 flow2_completed = 0;
3836 timevar_push (TV_FINAL);
3838 /* Clear out the insn_length contents now that they are no
3840 init_insn_lengths ();
3842 /* Show no temporary slots allocated. */
3845 free_basic_block_vars (0);
3846 free_bb_for_insn ();
3848 timevar_pop (TV_FINAL);
3850 if ((*targetm.binds_local_p) (current_function_decl))
3852 int pref = cfun->preferred_stack_boundary;
3853 if (cfun->recursive_call_emit
3854 && cfun->stack_alignment_needed > cfun->preferred_stack_boundary)
3855 pref = cfun->stack_alignment_needed;
3856 cgraph_rtl_info (current_function_decl)->preferred_incoming_stack_boundary
3860 /* Make sure volatile mem refs aren't considered valid operands for
3861 arithmetic insns. We must call this here if this is a nested inline
3862 function, since the above code leaves us in the init_recog state
3863 (from final.c), and the function context push/pop code does not
3864 save/restore volatile_ok.
3866 ??? Maybe it isn't necessary for expand_start_function to call this
3867 anymore if we do it here? */
3869 init_recog_no_volatile ();
3871 /* We're done with this function. Free up memory if we can. */
3872 free_after_parsing (cfun);
3873 if (! DECL_DEFER_OUTPUT (decl))
3875 free_after_compilation (cfun);
3877 /* Clear integrate.c's pointer to the cfun structure we just
3879 DECL_SAVED_INSNS (decl) = 0;
3885 timevar_pop (TV_REST_OF_COMPILATION);
3888 /* Display help for generic options. */
3896 printf (_(" -ffixed-<register> Mark <register> as being unavailable to the compiler\n"));
3897 printf (_(" -fcall-used-<register> Mark <register> as being corrupted by function calls\n"));
3898 printf (_(" -fcall-saved-<register> Mark <register> as being preserved across functions\n"));
3899 printf (_(" -finline-limit=<number> Limits the size of inlined functions to <number>\n"));
3900 printf (_(" -fmessage-length=<number> Limits diagnostics messages lengths to <number> characters per line. 0 suppresses line-wrapping\n"));
3901 printf (_(" -fdiagnostics-show-location=[once | every-line] Indicates how often source location information should be emitted, as prefix, at the beginning of diagnostics when line-wrapping\n"));
3902 printf (_(" -ftls-model=[global-dynamic | local-dynamic | initial-exec | local-exec] Indicates the default thread-local storage code generation model\n"));
3903 printf (_(" -fstack-limit-register=<register> Trap if the stack goes past <register>\n"));
3904 printf (_(" -fstack-limit-symbol=<name> Trap if the stack goes past symbol <name>\n"));
3905 printf (_(" -frandom-seed=<string> Make compile reproducible using <string>\n"));
3908 for (i = ARRAY_SIZE (f_options); i--;)
3910 const char *description = f_options[i].description;
3912 if (description != NULL && *description != 0)
3913 printf (" -f%-21s %s\n",
3914 f_options[i].string, _(description));
3917 printf (_(" -O[number] Set optimization level to [number]\n"));
3918 printf (_(" -Os Optimize for space rather than speed\n"));
3919 for (i = LAST_PARAM; i--;)
3921 const char *description = compiler_params[i].help;
3922 const int length = 21 - strlen (compiler_params[i].option);
3924 if (description != NULL && *description != 0)
3925 printf (" --param %s=<value>%.*s%s\n",
3926 compiler_params[i].option,
3927 length > 0 ? length : 1, " ",
3930 printf (_(" -pedantic Issue warnings needed by strict compliance to ISO C\n"));
3931 printf (_(" -pedantic-errors Like -pedantic except that errors are produced\n"));
3932 printf (_(" -w Suppress warnings\n"));
3934 for (i = ARRAY_SIZE (W_options); i--;)
3936 const char *description = W_options[i].description;
3938 if (description != NULL && *description != 0)
3939 printf (" -W%-21s %s\n",
3940 W_options[i].string, _(description));
3943 printf (_(" -Wextra Print extra (possibly unwanted) warnings\n"));
3944 printf (_(" -Wunused Enable unused warnings\n"));
3945 printf (_(" -Wlarger-than-<number> Warn if an object is larger than <number> bytes\n"));
3946 printf (_(" -p Enable function profiling\n"));
3947 printf (_(" -o <file> Place output into <file> \n"));
3949 -G <number> Put global and static data smaller than <number>\n\
3950 bytes into a special section (on some targets)\n"));
3952 for (i = ARRAY_SIZE (debug_args); i--;)
3954 if (debug_args[i].description != NULL)
3955 printf (" -g%-21s %s\n",
3956 debug_args[i].arg, _(debug_args[i].description));
3959 printf (_(" -aux-info <file> Emit declaration info into <file>\n"));
3960 printf (_(" -quiet Do not display functions compiled or elapsed time\n"));
3961 printf (_(" -version Display the compiler's version\n"));
3962 printf (_(" -d[letters] Enable dumps from specific passes of the compiler\n"));
3963 printf (_(" -dumpbase <file> Base name to be used for dumps from specific passes\n"));
3964 #if defined INSN_SCHEDULING
3965 printf (_(" -fsched-verbose=<number> Set the verbosity level of the scheduler\n"));
3967 printf (_(" --help Display this information\n"));
3972 /* Display descriptions of language specific options.
3973 If there is no description, note that there is an undocumented option.
3974 If the description is empty, do not display anything. (This allows
3975 options to be deliberately undocumented, for whatever reason).
3976 If the option string is missing, then this is a marker, indicating
3977 that the description string is in fact the name of a language, whose
3978 language specific options are to follow. */
3980 if (ARRAY_SIZE (documented_lang_options) > 1)
3982 printf (_("\nLanguage specific options:\n"));
3984 for (i = 0; i < ARRAY_SIZE (documented_lang_options); i++)
3986 const char *description = documented_lang_options[i].description;
3987 const char *option = documented_lang_options[i].option;
3989 if (description == NULL)
3994 printf (_(" %-23.23s [undocumented]\n"), option);
3996 else if (*description == 0)
3998 else if (option == NULL)
4002 (_("\nThere are undocumented %s specific options as well.\n"),
4006 printf (_("\n Options for %s:\n"), description);
4011 printf (" %-23.23s %s\n", option, _(description));
4016 printf (_("\nThere are undocumented %s specific options as well.\n"),
4019 display_target_options ();
4022 /* Display help for target options. */
4024 display_target_options (void)
4027 static bool displayed = false;
4029 /* Avoid double printing for --help --target-help. */
4035 if (ARRAY_SIZE (target_switches) > 1
4036 #ifdef TARGET_OPTIONS
4037 || ARRAY_SIZE (target_options) > 1
4045 printf (_("\nTarget specific options:\n"));
4047 for (i = ARRAY_SIZE (target_switches); i--;)
4049 const char *option = target_switches[i].name;
4050 const char *description = target_switches[i].description;
4052 if (option == NULL || *option == 0)
4054 else if (description == NULL)
4059 printf (_(" -m%-23.23s [undocumented]\n"), option);
4061 else if (*description != 0)
4062 doc += printf (" -m%-23.23s %s\n", option, _(description));
4065 #ifdef TARGET_OPTIONS
4066 for (i = ARRAY_SIZE (target_options); i--;)
4068 const char *option = target_options[i].prefix;
4069 const char *description = target_options[i].description;
4071 if (option == NULL || *option == 0)
4073 else if (description == NULL)
4078 printf (_(" -m%-23.23s [undocumented]\n"), option);
4080 else if (*description != 0)
4081 doc += printf (" -m%-23.23s %s\n", option, _(description));
4087 printf (_("\nThere are undocumented target specific options as well.\n"));
4089 printf (_(" They exist, but they are not documented.\n"));
4094 /* Parse a -d... command line switch. */
4097 decode_d_option (const char *arg)
4105 for (i = 0; i < (int) DFI_MAX; ++i)
4106 dump_file[i].enabled = 1;
4112 flag_print_asm_name = 1;
4115 flag_dump_rtl_in_asm = 1;
4116 flag_print_asm_name = 1;
4119 graph_dump_format = vcg;
4122 rtl_dump_and_exit = 1;
4127 case 'D': /* These are handled by the preprocessor. */
4131 setup_core_dumping();
4136 for (i = 0; i < (int) DFI_MAX; ++i)
4137 if (c == dump_file[i].debug_switch)
4139 dump_file[i].enabled = 1;
4144 warning ("unrecognized gcc debugging option: %c", c);
4149 /* Indexed by enum debug_info_type. */
4150 const char *const debug_type_names[] =
4152 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff", "vms"
4155 /* Parse a -g... command line switch. ARG is the value after the -g.
4156 It is safe to access 'ARG - 2' to generate the full switch name.
4157 Return the number of strings consumed. */
4160 decode_g_option (const char *arg)
4162 static unsigned level = 0;
4163 /* A lot of code assumes write_symbols == NO_DEBUG if the
4164 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
4165 of what debugging type has been selected). This records the
4166 selected type. It is an error to specify more than one
4168 static enum debug_info_type selected_debug_type = NO_DEBUG;
4169 /* Nonzero if debugging format has been explicitly set.
4170 -g and -ggdb don't explicitly set the debugging format so
4171 -gdwarf -g3 is equivalent to -gdwarf3. */
4172 static int type_explicitly_set_p = 0;
4174 /* The maximum admissible debug level value. */
4175 static const unsigned max_debug_level = 3;
4177 /* Look up ARG in the table. */
4178 for (da = debug_args; da->arg; da++)
4180 const int da_len = strlen (da->arg);
4182 if (da_len == 0 || ! strncmp (arg, da->arg, da_len))
4184 enum debug_info_type type = da->debug_type;
4185 const char *p = arg + da_len;
4187 if (*p && ! ISDIGIT (*p))
4190 /* A debug flag without a level defaults to level 2.
4191 Note we do not want to call read_integral_parameter
4192 for that case since it will call atoi which
4195 ??? We may want to generalize the interface to
4196 read_integral_parameter to better handle this case
4197 if this case shows up often. */
4199 level = read_integral_parameter (p, 0, max_debug_level + 1);
4201 level = (level == 0) ? 2 : level;
4203 if (da_len > 1 && *p && !strncmp (arg, "dwarf", da_len))
4205 error ("use -gdwarf -g%d for DWARF v1, level %d",
4208 error ("use -gdwarf-2 for DWARF v2");
4211 if (level > max_debug_level)
4214 ignoring option `%s' due to invalid debug level specification",
4216 level = debug_info_level;
4219 if (type == NO_DEBUG)
4221 type = PREFERRED_DEBUGGING_TYPE;
4223 if (da_len > 1 && strncmp (arg, "gdb", da_len) == 0)
4225 #ifdef DWARF2_DEBUGGING_INFO
4226 type = DWARF2_DEBUG;
4228 #ifdef DBX_DEBUGGING_INFO
4235 if (type == NO_DEBUG)
4236 warning ("`%s': unknown or unsupported -g option", arg - 2);
4238 /* Does it conflict with an already selected type? */
4239 if (type_explicitly_set_p
4240 /* -g/-ggdb don't conflict with anything. */
4241 && da->debug_type != NO_DEBUG
4242 && type != selected_debug_type)
4243 warning ("`%s' ignored, conflicts with `-g%s'",
4244 arg - 2, debug_type_names[(int) selected_debug_type]);
4247 /* If the format has already been set, -g/-ggdb
4248 only change the debug level. */
4249 if (type_explicitly_set_p && da->debug_type == NO_DEBUG)
4250 /* Don't change debugging type. */
4254 selected_debug_type = type;
4255 type_explicitly_set_p = da->debug_type != NO_DEBUG;
4258 write_symbols = (level == 0
4260 : selected_debug_type);
4261 use_gnu_debug_info_extensions = da->use_extensions_p;
4262 debug_info_level = (enum debug_info_level) level;
4270 warning ("`-g%s': unknown or unsupported -g option", arg);
4273 /* Decode -m switches. */
4274 /* Decode the switch -mNAME. */
4277 set_target_switch (const char *name)
4280 int valid_target_option = 0;
4282 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
4283 if (!strcmp (target_switches[j].name, name))
4285 if (target_switches[j].value < 0)
4286 target_flags &= ~-target_switches[j].value;
4288 target_flags |= target_switches[j].value;
4291 if (target_switches[j].value < 0)
4292 target_flags_explicit |= -target_switches[j].value;
4294 target_flags_explicit |= target_switches[j].value;
4296 valid_target_option = 1;
4299 #ifdef TARGET_OPTIONS
4300 if (!valid_target_option)
4301 for (j = 0; j < ARRAY_SIZE (target_options); j++)
4303 int len = strlen (target_options[j].prefix);
4304 if (target_options[j].value)
4306 if (!strcmp (target_options[j].prefix, name))
4308 *target_options[j].variable = target_options[j].value;
4309 valid_target_option = 1;
4314 if (!strncmp (target_options[j].prefix, name, len))
4316 *target_options[j].variable = name + len;
4317 valid_target_option = 1;
4323 if (!valid_target_option)
4324 error ("invalid option `%s'", name);
4327 /* Print version information to FILE.
4328 Each line begins with INDENT (for the case where FILE is the
4329 assembler output file). */
4332 print_version (FILE *file, const char *indent)
4335 #define __VERSION__ "[?]"
4339 "%s%s%s version %s (%s)\n%s\tcompiled by GNU C version %s.\n"
4341 "%s%s%s version %s (%s) compiled by CC.\n"
4343 , indent, *indent != 0 ? " " : "",
4344 lang_hooks.name, version_string, TARGET_NAME,
4345 indent, __VERSION__);
4346 fnotice (file, "%s%sGGC heuristics: --param ggc-min-expand=%d --param ggc-min-heapsize=%d\n",
4347 indent, *indent != 0 ? " " : "",
4348 PARAM_VALUE (GGC_MIN_EXPAND), PARAM_VALUE (GGC_MIN_HEAPSIZE));
4351 /* Print an option value and return the adjusted position in the line.
4352 ??? We don't handle error returns from fprintf (disk full); presumably
4353 other code will catch a disk full though. */
4356 print_single_switch (FILE *file, int pos, int max,
4357 const char *indent, const char *sep, const char *term,
4358 const char *type, const char *name)
4360 /* The ultrix fprintf returns 0 on success, so compute the result we want
4361 here since we need it for the following test. */
4362 int len = strlen (sep) + strlen (type) + strlen (name);
4367 fprintf (file, "%s", term);
4372 fprintf (file, "%s", indent);
4373 pos = strlen (indent);
4375 fprintf (file, "%s%s%s", sep, type, name);
4380 /* Print active target switches to FILE.
4381 POS is the current cursor position and MAX is the size of a "line".
4382 Each line begins with INDENT and ends with TERM.
4383 Each switch is separated from the next by SEP. */
4386 print_switch_values (FILE *file, int pos, int max,
4387 const char *indent, const char *sep, const char *term)
4392 /* Fill in the -frandom-seed option, if the user didn't pass it, so
4393 that it can be printed below. This helps reproducibility. Of
4394 course, the string may never be used, but we can't tell that at
4395 this point in the compile. */
4396 default_flag_random_seed ();
4398 /* Print the options as passed. */
4400 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
4401 _("options passed: "), "");
4403 for (p = &save_argv[1]; *p != NULL; p++)
4407 if (strcmp (*p, "-o") == 0)
4413 if (strcmp (*p, "-quiet") == 0)
4415 if (strcmp (*p, "-version") == 0)
4420 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
4423 fprintf (file, "%s", term);
4425 /* Print the -f and -m options that have been enabled.
4426 We don't handle language specific options but printing argv
4429 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
4430 _("options enabled: "), "");
4432 for (j = 0; j < ARRAY_SIZE (f_options); j++)
4433 if (*f_options[j].variable == f_options[j].on_value)
4434 pos = print_single_switch (file, pos, max, indent, sep, term,
4435 "-f", f_options[j].string);
4437 /* Print target specific options. */
4439 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
4440 if (target_switches[j].name[0] != '\0'
4441 && target_switches[j].value > 0
4442 && ((target_switches[j].value & target_flags)
4443 == target_switches[j].value))
4445 pos = print_single_switch (file, pos, max, indent, sep, term,
4446 "-m", target_switches[j].name);
4449 #ifdef TARGET_OPTIONS
4450 for (j = 0; j < ARRAY_SIZE (target_options); j++)
4451 if (*target_options[j].variable != NULL)
4454 sprintf (prefix, "-m%s", target_options[j].prefix);
4455 pos = print_single_switch (file, pos, max, indent, sep, term,
4456 prefix, *target_options[j].variable);
4460 fprintf (file, "%s", term);
4463 /* Open assembly code output file. Do this even if -fsyntax-only is
4464 on, because then the driver will have provided the name of a
4465 temporary file or bit bucket for us. NAME is the file specified on
4466 the command line, possibly NULL. */
4468 init_asm_output (const char *name)
4470 if (name == NULL && asm_file_name == 0)
4471 asm_out_file = stdout;
4474 if (asm_file_name == 0)
4476 int len = strlen (dump_base_name);
4477 char *dumpname = (char *) xmalloc (len + 6);
4478 memcpy (dumpname, dump_base_name, len + 1);
4479 strip_off_ending (dumpname, len);
4480 strcat (dumpname, ".s");
4481 asm_file_name = dumpname;
4483 if (!strcmp (asm_file_name, "-"))
4484 asm_out_file = stdout;
4486 asm_out_file = fopen (asm_file_name, "w+");
4487 if (asm_out_file == 0)
4488 fatal_error ("can't open %s for writing: %m", asm_file_name);
4491 #ifdef IO_BUFFER_SIZE
4492 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
4493 _IOFBF, IO_BUFFER_SIZE);
4496 if (!flag_syntax_only)
4498 targetm.asm_out.file_start ();
4500 #ifdef ASM_COMMENT_START
4501 if (flag_verbose_asm)
4503 /* Print the list of options in effect. */
4504 print_version (asm_out_file, ASM_COMMENT_START);
4505 print_switch_values (asm_out_file, 0, MAX_LINE,
4506 ASM_COMMENT_START, " ", "\n");
4507 /* Add a blank line here so it appears in assembler output but not
4509 fprintf (asm_out_file, "\n");
4515 /* Initialization of the front end environment, before command line
4516 options are parsed. Signal handlers, internationalization etc.
4517 ARGV0 is main's argv[0]. */
4519 general_init (char *argv0)
4523 p = argv0 + strlen (argv0);
4524 while (p != argv0 && !IS_DIR_SEPARATOR (p[-1]))
4528 xmalloc_set_program_name (progname);
4532 gcc_init_libintl ();
4534 /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages. */
4536 signal (SIGSEGV, crash_signal);
4539 signal (SIGILL, crash_signal);
4542 signal (SIGBUS, crash_signal);
4545 signal (SIGABRT, crash_signal);
4547 #if defined SIGIOT && (!defined SIGABRT || SIGABRT != SIGIOT)
4548 signal (SIGIOT, crash_signal);
4551 signal (SIGFPE, crash_signal);
4554 /* Other host-specific signal setup. */
4555 (*host_hooks.extra_signals)();
4557 /* Initialize the diagnostics reporting machinery, so option parsing
4558 can give warnings and errors. */
4559 diagnostic_initialize (global_dc);
4561 /* Initialize the garbage-collector, string pools and tree type hash
4568 /* Parse command line options and set default flag values, called
4569 after language-independent option-independent initialization. Do
4570 minimal options processing. Outputting diagnostics is OK, but GC
4571 and identifier hashtables etc. are not initialized yet.
4573 Return nonzero to suppress compiler back end initialization. */
4575 parse_options_and_default_flags (int argc, char **argv)
4579 /* Save in case md file wants to emit args as a comment. */
4583 /* Initialize register usage now so switches may override. */
4586 /* Register the language-independent parameters. */
4587 add_params (lang_independent_params, LAST_PARAM);
4589 /* This must be done after add_params but before argument processing. */
4590 init_ggc_heuristics();
4592 /* Perform language-specific options initialization. */
4593 lang_mask = (*lang_hooks.init_options) ();
4595 /* Scan to see what optimization level has been specified. That will
4596 determine the default value of many flags. */
4597 for (i = 1; i < argc; i++)
4599 if (!strcmp (argv[i], "-O"))
4604 else if (argv[i][0] == '-' && argv[i][1] == 'O')
4606 /* Handle -Os, -O2, -O3, -O69, ... */
4607 char *p = &argv[i][2];
4609 if ((p[0] == 's') && (p[1] == 0))
4613 /* Optimizing for size forces optimize to be 2. */
4618 const int optimize_val = read_integral_parameter (p, p - 2, -1);
4619 if (optimize_val != -1)
4621 optimize = optimize_val;
4630 flag_merge_constants = 0;
4636 flag_thread_jumps = 1;
4638 flag_delayed_branch = 1;
4640 #ifdef CAN_DEBUG_WITHOUT_FP
4641 flag_omit_frame_pointer = 1;
4643 flag_guess_branch_prob = 1;
4644 flag_cprop_registers = 1;
4645 flag_loop_optimize = 1;
4646 flag_crossjumping = 1;
4647 flag_if_conversion = 1;
4648 flag_if_conversion2 = 1;
4653 flag_optimize_sibling_calls = 1;
4654 flag_cse_follow_jumps = 1;
4655 flag_cse_skip_blocks = 1;
4657 flag_expensive_optimizations = 1;
4658 flag_strength_reduce = 1;
4659 flag_rerun_cse_after_loop = 1;
4660 flag_rerun_loop_opt = 1;
4661 flag_caller_saves = 1;
4664 #ifdef INSN_SCHEDULING
4665 flag_schedule_insns = 1;
4666 flag_schedule_insns_after_reload = 1;
4669 flag_strict_aliasing = 1;
4670 flag_delete_null_pointer_checks = 1;
4671 flag_reorder_blocks = 1;
4672 flag_reorder_functions = 1;
4677 flag_inline_functions = 1;
4678 flag_rename_registers = 1;
4679 flag_unswitch_loops = 1;
4680 flag_unit_at_a_time = 1;
4683 if (optimize < 2 || optimize_size)
4688 align_functions = 1;
4690 /* Don't reorder blocks when optimizing for size because extra
4691 jump insns may be created; also barrier may create extra padding.
4693 More correctly we should have a block reordering mode that tried
4694 to minimize the combined size of all the jumps. This would more
4695 or less automatically remove extra jumps, but would also try to
4696 use more short jumps instead of long jumps. */
4697 flag_reorder_blocks = 0;
4700 /* Initialize whether `char' is signed. */
4701 flag_signed_char = DEFAULT_SIGNED_CHAR;
4702 #ifdef DEFAULT_SHORT_ENUMS
4703 /* Initialize how much space enums occupy, by default. */
4704 flag_short_enums = DEFAULT_SHORT_ENUMS;
4707 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
4710 set_target_switch ("");
4712 /* Unwind tables are always present in an ABI-conformant IA-64
4713 object file, so the default should be ON. */
4714 #ifdef IA64_UNWIND_INFO
4715 flag_unwind_tables = IA64_UNWIND_INFO;
4718 #ifdef OPTIMIZATION_OPTIONS
4719 /* Allow default optimizations to be specified on a per-machine basis. */
4720 OPTIMIZATION_OPTIONS (optimize, optimize_size);
4723 /* Perform normal command line switch decoding. */
4724 for (i = 1; i < argc;)
4728 /* Give the language a chance to decode the option for itself. */
4729 processed = handle_option (argc - i, argv + i, lang_mask);
4735 const char *option = NULL;
4736 const char *lang = NULL;
4739 /* It is possible that the command line switch is not valid for the
4740 current language, but it is valid for another language. In order
4741 to be compatible with previous versions of the compiler (which
4742 did not issue an error message in this case) we check for this
4743 possibility here. If we do find a match, then if extra_warnings
4744 is set we generate a warning message, otherwise we will just
4745 ignore the option. */
4746 for (j = 0; j < ARRAY_SIZE (documented_lang_options); j++)
4748 option = documented_lang_options[j].option;
4751 lang = documented_lang_options[j].description;
4752 else if (! strncmp (argv[i], option, strlen (option)))
4756 if (j != ARRAY_SIZE (documented_lang_options))
4760 warning ("ignoring command line option '%s'", argv[i]);
4763 ("(it is valid for %s but not the selected language)",
4767 else if (argv[i][0] == '-' && argv[i][1] == 'g')
4768 warning ("`%s': unknown or unsupported -g option", &argv[i][2]);
4770 error ("unrecognized option `%s'", argv[i]);
4777 flag_pic = flag_pie;
4778 if (flag_pic && !flag_pie)
4781 if (flag_no_inline == 2)
4784 flag_really_no_inline = flag_no_inline;
4786 /* Set flag_no_inline before the post_options () hook. The C front
4787 ends use it to determine tree inlining defaults. FIXME: such
4788 code should be lang-independent when all front ends use tree
4789 inlining, in which case it, and this condition, should be moved
4790 to the top of process_options() instead. */
4793 /* Inlining does not work if not optimizing,
4794 so force it not to be done. */
4798 /* The c_decode_option function and decode_option hook set
4799 this to `2' if -Wall is used, so we can avoid giving out
4800 lots of errors for people who don't realize what -Wall does. */
4801 if (warn_uninitialized == 1)
4802 warning ("-Wuninitialized is not supported without -O");
4805 if (flag_really_no_inline == 2)
4806 flag_really_no_inline = flag_no_inline;
4809 /* Process the options that have been parsed. */
4811 process_options (void)
4813 /* Allow the front end to perform consistency checks and do further
4814 initialization based on the command line options. This hook also
4815 sets the original filename if appropriate (e.g. foo.i -> foo.c)
4816 so we can correctly initialize debug output. */
4817 no_backend = (*lang_hooks.post_options) (&main_input_filename);
4818 input_filename = main_input_filename;
4820 #ifdef OVERRIDE_OPTIONS
4821 /* Some machines may reject certain combinations of options. */
4825 /* Set aux_base_name if not already set. */
4828 else if (main_input_filename)
4830 char *name = xstrdup (lbasename (main_input_filename));
4832 strip_off_ending (name, strlen (name));
4833 aux_base_name = name;
4836 aux_base_name = "gccaux";
4838 /* Set up the align_*_log variables, defaulting them to 1 if they
4839 were still unset. */
4840 if (align_loops <= 0) align_loops = 1;
4841 if (align_loops_max_skip > align_loops || !align_loops)
4842 align_loops_max_skip = align_loops - 1;
4843 align_loops_log = floor_log2 (align_loops * 2 - 1);
4844 if (align_jumps <= 0) align_jumps = 1;
4845 if (align_jumps_max_skip > align_jumps || !align_jumps)
4846 align_jumps_max_skip = align_jumps - 1;
4847 align_jumps_log = floor_log2 (align_jumps * 2 - 1);
4848 if (align_labels <= 0) align_labels = 1;
4849 align_labels_log = floor_log2 (align_labels * 2 - 1);
4850 if (align_labels_max_skip > align_labels || !align_labels)
4851 align_labels_max_skip = align_labels - 1;
4852 if (align_functions <= 0) align_functions = 1;
4853 align_functions_log = floor_log2 (align_functions * 2 - 1);
4855 /* Unrolling all loops implies that standard loop unrolling must also
4857 if (flag_unroll_all_loops)
4858 flag_unroll_loops = 1;
4860 if (flag_unroll_loops)
4862 flag_old_unroll_loops = 0;
4863 flag_old_unroll_all_loops = 0;
4866 if (flag_old_unroll_all_loops)
4867 flag_old_unroll_loops = 1;
4869 /* Old loop unrolling requires that strength_reduction be on also. Silently
4870 turn on strength reduction here if it isn't already on. Also, the loop
4871 unrolling code assumes that cse will be run after loop, so that must
4872 be turned on also. */
4873 if (flag_old_unroll_loops)
4875 flag_strength_reduce = 1;
4876 flag_rerun_cse_after_loop = 1;
4878 if (flag_unroll_loops || flag_peel_loops)
4879 flag_rerun_cse_after_loop = 1;
4881 if (flag_non_call_exceptions)
4882 flag_asynchronous_unwind_tables = 1;
4883 if (flag_asynchronous_unwind_tables)
4884 flag_unwind_tables = 1;
4886 /* Disable unit-at-a-time mode for frontends not supporting callgraph
4888 if (flag_unit_at_a_time && ! lang_hooks.callgraph.expand_function)
4889 flag_unit_at_a_time = 0;
4891 /* Warn about options that are not supported on this machine. */
4892 #ifndef INSN_SCHEDULING
4893 if (flag_schedule_insns || flag_schedule_insns_after_reload)
4894 warning ("instruction scheduling not supported on this target machine");
4897 if (flag_delayed_branch)
4898 warning ("this target machine does not have delayed branches");
4901 user_label_prefix = USER_LABEL_PREFIX;
4902 if (flag_leading_underscore != -1)
4904 /* If the default prefix is more complicated than "" or "_",
4905 issue a warning and ignore this option. */
4906 if (user_label_prefix[0] == 0 ||
4907 (user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
4909 user_label_prefix = flag_leading_underscore ? "_" : "";
4912 warning ("-f%sleading-underscore not supported on this target machine",
4913 flag_leading_underscore ? "" : "no-");
4916 /* If we are in verbose mode, write out the version and maybe all the
4917 option flags in use. */
4920 print_version (stderr, "");
4922 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
4925 if (flag_syntax_only)
4927 write_symbols = NO_DEBUG;
4931 /* Now we know write_symbols, set up the debug hooks based on it.
4932 By default we do nothing for debug output. */
4933 #if defined(DBX_DEBUGGING_INFO)
4934 if (write_symbols == DBX_DEBUG)
4935 debug_hooks = &dbx_debug_hooks;
4937 #if defined(XCOFF_DEBUGGING_INFO)
4938 if (write_symbols == XCOFF_DEBUG)
4939 debug_hooks = &xcoff_debug_hooks;
4941 #ifdef SDB_DEBUGGING_INFO
4942 if (write_symbols == SDB_DEBUG)
4943 debug_hooks = &sdb_debug_hooks;
4945 #ifdef DWARF_DEBUGGING_INFO
4946 if (write_symbols == DWARF_DEBUG)
4947 debug_hooks = &dwarf_debug_hooks;
4949 #ifdef DWARF2_DEBUGGING_INFO
4950 if (write_symbols == DWARF2_DEBUG)
4951 debug_hooks = &dwarf2_debug_hooks;
4953 #ifdef VMS_DEBUGGING_INFO
4954 if (write_symbols == VMS_DEBUG || write_symbols == VMS_AND_DWARF2_DEBUG)
4955 debug_hooks = &vmsdbg_debug_hooks;
4958 /* If auxiliary info generation is desired, open the output file.
4959 This goes in the same directory as the source file--unlike
4960 all the other output files. */
4961 if (flag_gen_aux_info)
4963 aux_info_file = fopen (aux_info_file_name, "w");
4964 if (aux_info_file == 0)
4965 fatal_error ("can't open %s: %m", aux_info_file_name);
4968 if (! targetm.have_named_sections)
4970 if (flag_function_sections)
4972 warning ("-ffunction-sections not supported for this target");
4973 flag_function_sections = 0;
4975 if (flag_data_sections)
4977 warning ("-fdata-sections not supported for this target");
4978 flag_data_sections = 0;
4982 if (flag_function_sections && profile_flag)
4984 warning ("-ffunction-sections disabled; it makes profiling impossible");
4985 flag_function_sections = 0;
4988 #ifndef HAVE_prefetch
4989 if (flag_prefetch_loop_arrays)
4991 warning ("-fprefetch-loop-arrays not supported for this target");
4992 flag_prefetch_loop_arrays = 0;
4995 if (flag_prefetch_loop_arrays && !HAVE_prefetch)
4997 warning ("-fprefetch-loop-arrays not supported for this target (try -march switches)");
4998 flag_prefetch_loop_arrays = 0;
5002 /* This combination of options isn't handled for i386 targets and doesn't
5003 make much sense anyway, so don't allow it. */
5004 if (flag_prefetch_loop_arrays && optimize_size)
5006 warning ("-fprefetch-loop-arrays is not supported with -Os");
5007 flag_prefetch_loop_arrays = 0;
5010 #ifndef OBJECT_FORMAT_ELF
5011 if (flag_function_sections && write_symbols != NO_DEBUG)
5012 warning ("-ffunction-sections may affect debugging on some targets");
5015 /* The presence of IEEE signaling NaNs, implies all math can trap. */
5016 if (flag_signaling_nans)
5017 flag_trapping_math = 1;
5020 /* Initialize the compiler back end. */
5024 /* init_emit_once uses reg_raw_mode and therefore must be called
5025 after init_regs which initialized reg_raw_mode. */
5027 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
5028 || debug_info_level == DINFO_LEVEL_VERBOSE
5029 #ifdef VMS_DEBUGGING_INFO
5030 /* Enable line number info for traceback */
5031 || debug_info_level > DINFO_LEVEL_NONE
5033 || flag_test_coverage
5034 || warn_notreached);
5035 init_fake_stack_mems ();
5039 init_function_once ();
5040 init_varasm_once ();
5042 /* The following initialization functions need to generate rtl, so
5043 provide a dummy function context for them. */
5044 init_dummy_function_start ();
5046 if (flag_caller_saves)
5047 init_caller_save ();
5048 expand_dummy_function_end ();
5051 /* Language-dependent initialization. Returns nonzero on success. */
5053 lang_dependent_init (const char *name)
5055 if (dump_base_name == 0)
5056 dump_base_name = name ? name : "gccdump";
5058 /* Other front-end initialization. */
5059 if ((*lang_hooks.init) () == 0)
5062 init_asm_output (name);
5064 /* These create various _DECL nodes, so need to be called after the
5065 front end is initialized. */
5069 /* The following initialization functions need to generate rtl, so
5070 provide a dummy function context for them. */
5071 init_dummy_function_start ();
5073 expand_dummy_function_end ();
5075 /* If dbx symbol table desired, initialize writing it and output the
5076 predefined types. */
5077 timevar_push (TV_SYMOUT);
5079 #ifdef DWARF2_UNWIND_INFO
5080 if (dwarf2out_do_frame ())
5081 dwarf2out_frame_init ();
5084 /* Now we have the correct original filename, we can initialize
5086 (*debug_hooks->init) (name);
5088 timevar_pop (TV_SYMOUT);
5093 /* Clean up: close opened files, etc. */
5098 /* Close the dump files. */
5099 if (flag_gen_aux_info)
5101 fclose (aux_info_file);
5103 unlink (aux_info_file_name);
5106 /* Close non-debugging input and output files. Take special care to note
5107 whether fclose returns an error, since the pages might still be on the
5108 buffer chain while the file is open. */
5112 if (ferror (asm_out_file) != 0)
5113 fatal_error ("error writing to %s: %m", asm_file_name);
5114 if (fclose (asm_out_file) != 0)
5115 fatal_error ("error closing %s: %m", asm_file_name);
5118 /* Do whatever is necessary to finish printing the graphs. */
5119 if (graph_dump_format != no_graph)
5123 for (i = 0; i < (int) DFI_MAX; ++i)
5124 if (dump_file[i].initialized && dump_file[i].graph_dump_p)
5129 sprintf (seq, DUMPFILE_FORMAT, i);
5130 suffix = concat (seq, dump_file[i].extension, NULL);
5131 finish_graph_dump_file (dump_base_name, suffix);
5138 ggc_print_statistics ();
5139 stringpool_statistics ();
5140 dump_tree_statistics ();
5143 /* Free up memory for the benefit of leak detectors. */
5146 /* Language-specific end of compilation actions. */
5147 (*lang_hooks.finish) ();
5150 /* Initialize the compiler, and compile the input file. */
5154 /* Initialize timing first. The C front ends read the main file in
5155 the post_options hook, and C++ does file timings. */
5156 if (time_report || !quiet_flag || flag_detailed_statistics)
5158 timevar_start (TV_TOTAL);
5162 /* Don't do any more if an error has already occurred. */
5165 /* Set up the back-end if requested. */
5169 /* Language-dependent initialization. Returns true on success. */
5170 if (lang_dependent_init (main_input_filename))
5176 /* Stop timing and print the times. */
5177 timevar_stop (TV_TOTAL);
5178 timevar_print (stderr);
5181 /* Entry point of cc1, cc1plus, jc1, f771, etc.
5182 Decode command args, then call compile_file.
5183 Exit code is FATAL_EXIT_CODE if can't open files or if there were
5184 any errors, or SUCCESS_EXIT_CODE if compilation succeeded.
5186 It is not safe to call this function more than once. */
5189 toplev_main (int argc, char **argv)
5191 /* Initialization of GCC's environment, and diagnostics. */
5192 general_init (argv[0]);
5194 /* Parse the options and do minimal processing; basically just
5195 enough to default flags appropriately. */
5196 parse_options_and_default_flags (argc, argv);
5198 /* Exit early if we can (e.g. -help). */
5199 if (!exit_after_options)
5202 if (errorcount || sorrycount)
5203 return (FATAL_EXIT_CODE);
5205 return (SUCCESS_EXIT_CODE);