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 means emit debugging information only for symbols which are used. */
406 int flag_debug_only_used_symbols = 0;
408 /* Nonzero if generating code to do profiling. */
410 int profile_flag = 0;
412 /* Nonzero if generating code to profile program flow graph arcs. */
414 int profile_arc_flag = 0;
416 /* Nonzero if value histograms should be measured. */
418 int flag_profile_values = 0;
420 /* Nonzero if generating info for gcov to calculate line test coverage. */
422 int flag_test_coverage = 0;
424 /* Nonzero indicates that branch taken probabilities should be calculated. */
426 int flag_branch_probabilities = 0;
428 /* Nonzero if basic blocks should be reordered. */
430 int flag_reorder_blocks = 0;
432 /* Nonzero if functions should be reordered. */
434 int flag_reorder_functions = 0;
436 /* Nonzero if registers should be renamed. */
438 int flag_rename_registers = 0;
439 int flag_cprop_registers = 0;
441 /* Nonzero for -pedantic switch: warn about anything
442 that standard spec forbids. */
446 /* Temporarily suppress certain warnings.
447 This is set while reading code from a system header file. */
449 int in_system_header = 0;
451 /* Don't print functions as they are compiled. -quiet. */
455 /* Print times taken by the various passes. -ftime-report. */
459 /* Print memory still in use at end of compilation (which may have little
460 to do with peak memory consumption). -fmem-report. */
464 /* Nonzero means to collect statistics which might be expensive
465 and to print them when we are done. */
466 int flag_detailed_statistics = 0;
470 /* Nonzero means `char' should be signed. */
472 int flag_signed_char;
474 /* Nonzero means give an enum type only as many bytes as it needs. */
476 int flag_short_enums;
478 /* Nonzero for -fcaller-saves: allocate values in regs that need to
479 be saved across function calls, if that produces overall better code.
480 Optional now, so people can test it. */
482 #ifdef DEFAULT_CALLER_SAVES
483 int flag_caller_saves = 1;
485 int flag_caller_saves = 0;
488 /* Nonzero if structures and unions should be returned in memory.
490 This should only be defined if compatibility with another compiler or
491 with an ABI is needed, because it results in slower code. */
493 #ifndef DEFAULT_PCC_STRUCT_RETURN
494 #define DEFAULT_PCC_STRUCT_RETURN 1
497 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
499 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
501 /* Nonzero for -fforce-mem: load memory value into a register
502 before arithmetic on it. This makes better cse but slower compilation. */
504 int flag_force_mem = 0;
506 /* Nonzero for -fforce-addr: load memory address into a register before
507 reference to memory. This makes better cse but slower compilation. */
509 int flag_force_addr = 0;
511 /* Nonzero for -fdefer-pop: don't pop args after each function call;
512 instead save them up to pop many calls' args with one insns. */
514 int flag_defer_pop = 0;
516 /* Nonzero for -ffloat-store: don't allocate floats and doubles
517 in extended-precision registers. */
519 int flag_float_store = 0;
521 /* Nonzero for -fcse-follow-jumps:
522 have cse follow jumps to do a more extensive job. */
524 int flag_cse_follow_jumps;
526 /* Nonzero for -fcse-skip-blocks:
527 have cse follow a branch around a block. */
528 int flag_cse_skip_blocks;
530 /* Nonzero for -fexpensive-optimizations:
531 perform miscellaneous relatively-expensive optimizations. */
532 int flag_expensive_optimizations;
534 /* Nonzero for -fthread-jumps:
535 have jump optimize output of loop. */
537 int flag_thread_jumps;
539 /* Nonzero enables strength-reduction in loop.c. */
541 int flag_strength_reduce = 0;
543 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
544 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
545 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
548 int flag_old_unroll_loops;
550 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
551 This is generally not a win. */
553 int flag_old_unroll_all_loops;
555 /* Enables unrolling of simple loops in loop-unroll.c. */
556 int flag_unroll_loops;
558 /* Enables unrolling of all loops in loop-unroll.c. */
559 int flag_unroll_all_loops;
561 /* Nonzero enables loop peeling. */
564 /* Nonzero enables loop unswitching. */
565 int flag_unswitch_loops;
567 /* Nonzero enables prefetch optimizations for arrays in loops. */
569 int flag_prefetch_loop_arrays;
571 /* Nonzero forces all invariant computations in loops to be moved
574 int flag_move_all_movables = 0;
576 /* Nonzero forces all general induction variables in loops to be
579 int flag_reduce_all_givs = 0;
581 /* Nonzero to perform full register move optimization passes. This is the
584 int flag_regmove = 0;
586 /* Nonzero for -fwritable-strings:
587 store string constants in data segment and don't uniquize them. */
589 int flag_writable_strings = 0;
591 /* Nonzero means don't put addresses of constant functions in registers.
592 Used for compiling the Unix kernel, where strange substitutions are
593 done on the assembly output. */
595 int flag_no_function_cse = 0;
597 /* Nonzero for -fomit-frame-pointer:
598 don't make a frame pointer in simple functions that don't require one. */
600 int flag_omit_frame_pointer = 0;
602 /* Nonzero means place each function into its own section on those platforms
603 which support arbitrary section names and unlimited numbers of sections. */
605 int flag_function_sections = 0;
607 /* ... and similar for data. */
609 int flag_data_sections = 0;
611 /* Nonzero to inhibit use of define_optimization peephole opts. */
613 int flag_no_peephole = 0;
615 /* Nonzero allows GCC to optimize sibling and tail recursive calls. */
617 int flag_optimize_sibling_calls = 0;
619 /* Nonzero means the front end generally wants `errno' maintained by math
620 operations, like built-in SQRT. */
622 int flag_errno_math = 1;
624 /* Nonzero means that unsafe floating-point math optimizations are allowed
625 for the sake of speed. IEEE compliance is not guaranteed, and operations
626 are allowed to assume that their arguments and results are "normal"
627 (e.g., nonnegative for SQRT). */
629 int flag_unsafe_math_optimizations = 0;
631 /* Nonzero means that no NaNs or +-Infs are expected. */
633 int flag_finite_math_only = 0;
635 /* Zero means that floating-point math operations cannot generate a
636 (user-visible) trap. This is the case, for example, in nonstop
637 IEEE 754 arithmetic. Trapping conditions include division by zero,
638 overflow, underflow, invalid and inexact, but does not include
639 operations on signaling NaNs (see below). */
641 int flag_trapping_math = 1;
643 /* Nonzero means disable transformations observable by signaling NaNs.
644 This option implies that any operation on an IEEE signaling NaN can
645 generate a (user-visible) trap. */
647 int flag_signaling_nans = 0;
649 /* 0 means straightforward implementation of complex divide acceptable.
650 1 means wide ranges of inputs must work for complex divide.
651 2 means C99-like requirements for complex divide (not yet implemented). */
653 int flag_complex_divide_method = 0;
655 /* Nonzero means just do syntax checking; don't output anything. */
657 int flag_syntax_only = 0;
659 /* Nonzero means perform loop optimizer. */
661 int flag_loop_optimize;
663 /* Nonzero means perform crossjumping. */
665 int flag_crossjumping;
667 /* Nonzero means perform if conversion. */
669 int flag_if_conversion;
671 /* Nonzero means perform if conversion after reload. */
673 int flag_if_conversion2;
675 /* Nonzero means to use global dataflow analysis to eliminate
676 useless null pointer tests. */
678 int flag_delete_null_pointer_checks;
680 /* Nonzero means perform global CSE. */
684 /* Nonzero means to do the enhanced load motion during gcse, which trys
685 to hoist loads by not killing them when a store to the same location
688 int flag_gcse_lm = 1;
690 /* Nonzero means to perform store motion after gcse, which will try to
691 move stores closer to the exit block. Its not very effective without
694 int flag_gcse_sm = 1;
696 /* Perform target register optimization before prologue / epilogue
699 int flag_branch_target_load_optimize = 0;
701 /* Perform target register optimization after prologue / epilogue
702 threading and jump2. */
704 int flag_branch_target_load_optimize2 = 0;
706 /* Nonzero means to rerun cse after loop optimization. This increases
707 compilation time about 20% and picks up a few more common expressions. */
709 int flag_rerun_cse_after_loop;
711 /* Nonzero means to run loop optimizations twice. */
713 int flag_rerun_loop_opt;
715 /* Nonzero for -finline-functions: ok to inline functions that look like
716 good inline candidates. */
718 int flag_inline_functions;
720 /* Nonzero for -fkeep-inline-functions: even if we make a function
721 go inline everywhere, keep its definition around for debugging
724 int flag_keep_inline_functions;
726 /* Nonzero means that functions will not be inlined. */
728 int flag_no_inline = 2;
730 /* Nonzero means that we don't want inlining by virtue of -fno-inline,
731 not just because the tree inliner turned us off. */
733 int flag_really_no_inline = 2;
735 /* Nonzero means that we should emit static const variables
736 regardless of whether or not optimization is turned on. */
738 int flag_keep_static_consts = 1;
740 /* Nonzero means we should be saving declaration info into a .X file. */
742 int flag_gen_aux_info = 0;
744 /* Specified name of aux-info file. */
746 const char *aux_info_file_name;
748 /* Nonzero means make the text shared if supported. */
750 int flag_shared_data;
752 /* Nonzero means schedule into delayed branch slots if supported. */
754 int flag_delayed_branch;
756 /* Nonzero if we are compiling pure (sharable) code.
757 Value is 1 if we are doing "small" pic; value is 2 if we're doing
762 /* Nonzero if we are compiling position independent code for executable.
763 The value is 1 if we are doing "small" pic; value is 2 if we're doing
768 /* Nonzero if we are compiling code for a shared library, zero for
773 /* Set to the default thread-local storage (tls) model to use. */
775 enum tls_model flag_tls_default = TLS_MODEL_GLOBAL_DYNAMIC;
777 /* Nonzero means generate extra code for exception handling and enable
778 exception handling. */
782 /* Nonzero means generate frame unwind info table when supported. */
784 int flag_unwind_tables = 0;
786 /* Nonzero means generate frame unwind info table exact at each insn boundary */
788 int flag_asynchronous_unwind_tables = 0;
790 /* Nonzero means don't place uninitialized global data in common storage
795 /* Nonzero means change certain warnings into errors.
796 Usually these are warnings about failure to conform to some standard. */
798 int flag_pedantic_errors = 0;
800 /* flag_schedule_insns means schedule insns within basic blocks (before
802 flag_schedule_insns_after_reload means schedule insns after
805 int flag_schedule_insns = 0;
806 int flag_schedule_insns_after_reload = 0;
808 /* When flag_schedule_insns_after_reload is set, use EBB scheduler. */
809 int flag_sched2_use_superblocks = 0;
811 /* When flag_schedule_insns_after_reload is set, construct traces and EBB
813 int flag_sched2_use_traces = 0;
815 /* The following flags have effect only for scheduling before register
818 flag_schedule_interblock means schedule insns across basic blocks.
819 flag_schedule_speculative means allow speculative motion of non-load insns.
820 flag_schedule_speculative_load means allow speculative motion of some
822 flag_schedule_speculative_load_dangerous allows speculative motion of more
825 int flag_schedule_interblock = 1;
826 int flag_schedule_speculative = 1;
827 int flag_schedule_speculative_load = 0;
828 int flag_schedule_speculative_load_dangerous = 0;
830 int flag_single_precision_constant;
832 /* flag_branch_on_count_reg means try to replace add-1,compare,branch tupple
833 by a cheaper branch on a count register. */
834 int flag_branch_on_count_reg = 1;
836 /* -finhibit-size-directive inhibits output of .size for ELF.
837 This is used only for compiling crtstuff.c,
838 and it may be extended to other effects
839 needed for crtstuff.c on other systems. */
840 int flag_inhibit_size_directive = 0;
842 /* -fverbose-asm causes extra commentary information to be produced in
843 the generated assembly code (to make it more readable). This option
844 is generally only of use to those who actually need to read the
845 generated assembly code (perhaps while debugging the compiler itself).
846 -fno-verbose-asm, the default, causes the extra information
847 to be omitted and is useful when comparing two assembler files. */
849 int flag_verbose_asm = 0;
851 /* -dA causes debug commentary information to be produced in
852 the generated assembly code (to make it more readable). This option
853 is generally only of use to those who actually need to read the
854 generated assembly code (perhaps while debugging the compiler itself).
855 Currently, this switch is only used by dwarfout.c; however, it is intended
856 to be a catchall for printing debug information in the assembler file. */
858 int flag_debug_asm = 0;
860 /* -dP causes the rtl to be emitted as a comment in assembly. */
862 int flag_dump_rtl_in_asm = 0;
864 /* -fgnu-linker specifies use of the GNU linker for initializations.
865 (Or, more generally, a linker that handles initializations.)
866 -fno-gnu-linker says that collect2 will be used. */
868 int flag_gnu_linker = 0;
870 int flag_gnu_linker = 1;
873 /* Nonzero means put zero initialized data in the bss section. */
874 int flag_zero_initialized_in_bss = 1;
879 /* Enable ssa conditional constant propagation. */
880 int flag_ssa_ccp = 0;
882 /* Enable ssa aggressive dead code elimination. */
883 int flag_ssa_dce = 0;
885 /* Tag all structures with __attribute__(packed). */
886 int flag_pack_struct = 0;
888 /* Emit code to check for stack overflow; also may cause large objects
889 to be allocated dynamically. */
890 int flag_stack_check;
892 /* When non-NULL, indicates that whenever space is allocated on the
893 stack, the resulting stack pointer must not pass this
894 address---that is, for stacks that grow downward, the stack pointer
895 must always be greater than or equal to this address; for stacks
896 that grow upward, the stack pointer must be less than this address.
897 At present, the rtx may be either a REG or a SYMBOL_REF, although
898 the support provided depends on the backend. */
901 /* 0 if pointer arguments may alias each other. True in C.
902 1 if pointer arguments may not alias each other but may alias
904 2 if pointer arguments may not alias each other and may not
905 alias global variables. True in Fortran.
906 This defaults to 0 for C. */
907 int flag_argument_noalias = 0;
909 /* Nonzero if we should do (language-dependent) alias analysis.
910 Typically, this analysis will assume that expressions of certain
911 types do not alias expressions of certain other types. Only used
912 if alias analysis (in general) is enabled. */
913 int flag_strict_aliasing = 0;
915 /* Instrument functions with calls at entry and exit, for profiling. */
916 int flag_instrument_function_entry_exit = 0;
918 /* Nonzero means ignore `#ident' directives. 0 means handle them.
919 On SVR4 targets, it also controls whether or not to emit a
920 string identifying the compiler. */
922 int flag_no_ident = 0;
924 /* This will perform a peephole pass before sched2. */
925 int flag_peephole2 = 0;
927 /* This will try to guess branch probabilities. */
928 int flag_guess_branch_prob = 0;
930 /* -fcheck-bounds causes gcc to generate array bounds checks.
931 For C, C++, ObjC: defaults to off.
932 For Java: defaults to on.
933 For Fortran: defaults to off. */
934 int flag_bounds_check = 0;
936 /* This will attempt to merge constant section constants, if 1 only
937 string constants and constants from constant pool, if 2 also constant
939 int flag_merge_constants = 1;
941 /* If one, renumber instruction UIDs to reduce the number of
942 unused UIDs if there are a lot of instructions. If greater than
943 one, unconditionally renumber instruction UIDs. */
944 int flag_renumber_insns = 1;
946 /* If nonzero, use the graph coloring register allocator. */
947 int flag_new_regalloc = 0;
949 /* Nonzero if we perform superblock formation. */
953 /* Nonzero if we perform whole unit at a time compilation. */
955 int flag_unit_at_a_time = 0;
957 /* Values of the -falign-* flags: how much to align labels in code.
958 0 means `use default', 1 means `don't align'.
959 For each variable, there is an _log variant which is the power
960 of two not less than the variable, for .align output. */
964 int align_loops_max_skip;
967 int align_jumps_max_skip;
969 int align_labels_log;
970 int align_labels_max_skip;
972 int align_functions_log;
974 /* Like align_functions_log above, but used by front-ends to force the
975 minimum function alignment. Zero means no alignment is forced. */
976 int force_align_functions_log;
978 /* Table of supported debugging formats. */
981 const char *const arg;
982 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
983 constant expression, we use NO_DEBUG in its place. */
984 const enum debug_info_type debug_type;
985 const int use_extensions_p;
986 const char *const description;
990 { "", NO_DEBUG, DEFAULT_GDB_EXTENSIONS,
991 N_("Generate debugging info in default format") },
992 { "gdb", NO_DEBUG, 1, N_("Generate debugging info in default extended format") },
993 #ifdef DBX_DEBUGGING_INFO
994 { "stabs", DBX_DEBUG, 0, N_("Generate STABS format debug info") },
995 { "stabs+", DBX_DEBUG, 1, N_("Generate extended STABS format debug info") },
997 #ifdef DWARF_DEBUGGING_INFO
998 { "dwarf", DWARF_DEBUG, 0, N_("Generate DWARF-1 format debug info") },
999 { "dwarf+", DWARF_DEBUG, 1,
1000 N_("Generate extended DWARF-1 format debug info") },
1002 #ifdef DWARF2_DEBUGGING_INFO
1003 { "dwarf-2", DWARF2_DEBUG, 0, N_("Generate DWARF-2 debug info") },
1005 #ifdef XCOFF_DEBUGGING_INFO
1006 { "xcoff", XCOFF_DEBUG, 0, N_("Generate XCOFF format debug info") },
1007 { "xcoff+", XCOFF_DEBUG, 1, N_("Generate extended XCOFF format debug info") },
1009 #ifdef SDB_DEBUGGING_INFO
1010 { "coff", SDB_DEBUG, 0, N_("Generate COFF format debug info") },
1012 #ifdef VMS_DEBUGGING_INFO
1013 { "vms", VMS_DEBUG, 0, N_("Generate VMS format debug info") },
1020 const char *const string;
1021 int *const variable;
1023 const char *const description;
1025 lang_independent_options;
1027 /* Nonzero if signed arithmetic overflow should trap. */
1030 /* Nonzero if signed arithmetic overflow should wrap around. */
1033 /* Add or remove a leading underscore from user symbols. */
1034 int flag_leading_underscore = -1;
1036 /* The user symbol prefix after having resolved same. */
1037 const char *user_label_prefix;
1039 static const param_info lang_independent_params[] = {
1040 #define DEFPARAM(ENUM, OPTION, HELP, DEFAULT) \
1041 { OPTION, DEFAULT, HELP },
1042 #include "params.def"
1047 /* Used for the f_options array temporarily. */
1048 static int flag_dummy;
1050 /* Table of language-independent -f options.
1051 STRING is the option name. VARIABLE is the address of the variable.
1052 ON_VALUE is the value to store in VARIABLE
1053 if `-fSTRING' is seen as an option.
1054 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
1056 static const lang_independent_options f_options[] =
1058 {"eliminate-dwarf2-dups", &flag_dummy, 1,
1059 N_("Perform DWARF2 duplicate elimination") },
1060 {"eliminate-unused-debug-types", &flag_dummy, 1,
1061 N_("Perform unused type elimination in debug info") },
1062 {"eliminate-unused-debug-symbols", &flag_dummy, 1,
1063 N_("Perform unused type elimination in debug info") },
1064 {"float-store", &flag_dummy, 1,
1065 N_("Do not store floats in registers") },
1066 {"defer-pop", &flag_dummy, 1,
1067 N_("Defer popping functions args from stack until later") },
1068 {"omit-frame-pointer", &flag_dummy, 1,
1069 N_("When possible do not generate stack frames") },
1070 {"optimize-sibling-calls", &flag_dummy, 1,
1071 N_("Optimize sibling and tail recursive calls") },
1072 {"tracer", &flag_dummy, 1,
1073 N_("Perform superblock formation via tail duplication") },
1074 {"unit-at-a-time", &flag_dummy, 1,
1075 N_("Compile whole compilation unit at a time") },
1076 {"cse-follow-jumps", &flag_dummy, 1,
1077 N_("When running CSE, follow jumps to their targets") },
1078 {"cse-skip-blocks", &flag_dummy, 1,
1079 N_("When running CSE, follow conditional jumps") },
1080 {"expensive-optimizations", &flag_dummy, 1,
1081 N_("Perform a number of minor, expensive optimizations") },
1082 {"thread-jumps", &flag_dummy, 1,
1083 N_("Perform jump threading optimizations") },
1084 {"strength-reduce", &flag_dummy, 1,
1085 N_("Perform strength reduction optimizations") },
1086 {"unroll-loops", &flag_dummy, 1,
1087 N_("Perform loop unrolling when iteration count is known") },
1088 {"unroll-all-loops", &flag_dummy, 1,
1089 N_("Perform loop unrolling for all loops") },
1090 {"old-unroll-loops", &flag_dummy, 1,
1091 N_("Perform loop unrolling when iteration count is known") },
1092 {"old-unroll-all-loops", &flag_dummy, 1,
1093 N_("Perform loop unrolling for all loops") },
1094 {"peel-loops", &flag_dummy, 1,
1095 N_("Perform loop peeling") },
1096 {"unswitch-loops", &flag_dummy, 1,
1097 N_("Perform loop unswitching") },
1098 {"prefetch-loop-arrays", &flag_dummy, 1,
1099 N_("Generate prefetch instructions, if available, for arrays in loops") },
1100 {"move-all-movables", &flag_dummy, 1,
1101 N_("Force all loop invariant computations out of loops") },
1102 {"reduce-all-givs", &flag_dummy, 1,
1103 N_("Strength reduce all loop general induction variables") },
1104 {"writable-strings", &flag_dummy, 1,
1105 N_("Store strings in writable data section") },
1106 {"peephole", &flag_dummy, 0,
1107 N_("Enable machine specific peephole optimizations") },
1108 {"force-mem", &flag_dummy, 1,
1109 N_("Copy memory operands into registers before using") },
1110 {"force-addr", &flag_dummy, 1,
1111 N_("Copy memory address constants into regs before using") },
1112 {"function-cse", &flag_dummy, 0,
1113 N_("Allow function addresses to be held in registers") },
1114 {"inline-functions", &flag_dummy, 1,
1115 N_("Integrate simple functions into their callers") },
1116 {"keep-inline-functions", &flag_dummy, 1,
1117 N_("Generate code for funcs even if they are fully inlined") },
1118 {"inline", &flag_dummy, 0,
1119 N_("Pay attention to the 'inline' keyword") },
1120 {"keep-static-consts", &flag_dummy, 1,
1121 N_("Emit static const variables even if they are not used") },
1122 {"syntax-only", &flag_dummy, 1,
1123 N_("Check for syntax errors, then stop") },
1124 {"shared-data", &flag_dummy, 1,
1125 N_("Mark data as shared rather than private") },
1126 {"caller-saves", &flag_dummy, 1,
1127 N_("Enable saving registers around function calls") },
1128 {"pcc-struct-return", &flag_dummy, 1,
1129 N_("Return 'short' aggregates in memory, not registers") },
1130 {"reg-struct-return", &flag_dummy, 0,
1131 N_("Return 'short' aggregates in registers") },
1132 {"delayed-branch", &flag_dummy, 1,
1133 N_("Attempt to fill delay slots of branch instructions") },
1134 {"gcse", &flag_dummy, 1,
1135 N_("Perform the global common subexpression elimination") },
1136 {"gcse-lm", &flag_dummy, 1,
1137 N_("Perform enhanced load motion during global subexpression elimination") },
1138 {"gcse-sm", &flag_dummy, 1,
1139 N_("Perform store motion after global subexpression elimination") },
1140 {"branch-target-load-optimize", &flag_dummy, 1,
1141 N_("Perform branch target load optimization before prologue / epilogue threading") },
1142 {"branch-target-load-optimize2", &flag_dummy, 1,
1143 N_("Perform branch target load optimization after prologue / epilogue threading") },
1144 {"loop-optimize", &flag_dummy, 1,
1145 N_("Perform the loop optimizations") },
1146 {"crossjumping", &flag_dummy, 1,
1147 N_("Perform cross-jumping optimization") },
1148 {"if-conversion", &flag_dummy, 1,
1149 N_("Perform conversion of conditional jumps to branchless equivalents") },
1150 {"if-conversion2", &flag_dummy, 1,
1151 N_("Perform conversion of conditional jumps to conditional execution") },
1152 {"rerun-cse-after-loop", &flag_dummy, 1,
1153 N_("Run CSE pass after loop optimizations") },
1154 {"rerun-loop-opt", &flag_dummy, 1,
1155 N_("Run the loop optimizer twice") },
1156 {"delete-null-pointer-checks", &flag_dummy, 1,
1157 N_("Delete useless null pointer checks") },
1158 {"schedule-insns", &flag_dummy, 1,
1159 N_("Reschedule instructions before register allocation") },
1160 {"schedule-insns2", &flag_dummy, 1,
1161 N_("Reschedule instructions after register allocation") },
1162 {"sched-interblock",&flag_dummy, 1,
1163 N_("Enable scheduling across basic blocks") },
1164 {"sched-spec",&flag_dummy, 1,
1165 N_("Allow speculative motion of non-loads") },
1166 {"sched-spec-load",&flag_dummy, 1,
1167 N_("Allow speculative motion of some loads") },
1168 {"sched-spec-load-dangerous",&flag_dummy, 1,
1169 N_("Allow speculative motion of more loads") },
1170 {"sched2-use-superblocks", &flag_dummy, 1,
1171 N_("If scheduling post reload, do superblock scheduling") },
1172 {"sched2-use-traces", &flag_dummy, 1,
1173 N_("If scheduling post reload, do trace scheduling") },
1174 {"branch-count-reg",&flag_dummy, 1,
1175 N_("Replace add,compare,branch with branch on count reg") },
1176 {"pic", &flag_dummy, 1,
1177 N_("Generate position independent code, if possible") },
1178 {"PIC", &flag_dummy, 2, ""},
1179 {"pie", &flag_dummy, 1,
1180 N_("Generate position independent code for executables, if possible") },
1181 {"PIE", &flag_dummy, 2, ""},
1182 {"exceptions", &flag_dummy, 1,
1183 N_("Enable exception handling") },
1184 {"unwind-tables", &flag_dummy, 1,
1185 N_("Just generate unwind tables for exception handling") },
1186 {"asynchronous-unwind-tables", &flag_dummy, 1,
1187 N_("Generate unwind tables exact at each instruction boundary") },
1188 {"non-call-exceptions", &flag_dummy, 1,
1189 N_("Support synchronous non-call exceptions") },
1190 {"profile-arcs", &flag_dummy, 1,
1191 N_("Insert arc based program profiling code") },
1192 {"test-coverage", &flag_dummy, 1,
1193 N_("Create data files needed by gcov") },
1194 {"branch-probabilities", &flag_dummy, 1,
1195 N_("Use profiling information for branch probabilities") },
1196 {"profile-values", &flag_profile_values, 1,
1197 N_("Insert code to profile values of expressions") },
1198 {"profile", &flag_dummy, 1,
1199 N_("Enable basic program profiling code") },
1200 {"reorder-blocks", &flag_dummy, 1,
1201 N_("Reorder basic blocks to improve code placement") },
1202 {"reorder-functions", &flag_dummy, 1,
1203 N_("Reorder functions to improve code placement") },
1204 {"rename-registers", &flag_dummy, 1,
1205 N_("Do the register renaming optimization pass") },
1206 {"cprop-registers", &flag_dummy, 1,
1207 N_("Do the register copy-propagation optimization pass") },
1208 {"common", &flag_dummy, 0,
1209 N_("Do not put uninitialized globals in the common section") },
1210 {"inhibit-size-directive", &flag_dummy, 1,
1211 N_("Do not generate .size directives") },
1212 {"function-sections", &flag_dummy, 1,
1213 N_("place each function into its own section") },
1214 {"data-sections", &flag_dummy, 1,
1215 N_("place data items into their own section") },
1216 {"verbose-asm", &flag_dummy, 1,
1217 N_("Add extra commentary to assembler output") },
1218 {"gnu-linker", &flag_dummy, 1,
1219 N_("Output GNU ld formatted global initializers") },
1220 {"regmove", &flag_dummy, 1,
1221 N_("Enables a register move optimization") },
1222 {"optimize-register-move", &flag_dummy, 1,
1223 N_("Do the full regmove optimization pass") },
1224 {"pack-struct", &flag_dummy, 1,
1225 N_("Pack structure members together without holes") },
1226 {"stack-check", &flag_dummy, 1,
1227 N_("Insert stack checking code into the program") },
1228 {"argument-alias", &flag_dummy, 0,
1229 N_("Specify that arguments may alias each other & globals") },
1230 {"argument-noalias", &flag_dummy, 1,
1231 N_("Assume arguments may alias globals but not each other") },
1232 {"argument-noalias-global", &flag_dummy, 2,
1233 N_("Assume arguments do not alias each other or globals") },
1234 {"strict-aliasing", &flag_dummy, 1,
1235 N_("Assume strict aliasing rules apply") },
1236 {"align-loops", &flag_dummy, 0,
1237 N_("Align the start of loops") },
1238 {"align-jumps", &flag_dummy, 0,
1239 N_("Align labels which are only reached by jumping") },
1240 {"align-labels", &flag_dummy, 0,
1241 N_("Align all labels") },
1242 {"align-functions", &flag_dummy, 0,
1243 N_("Align the start of functions") },
1244 {"merge-constants", &flag_dummy, 1,
1245 N_("Attempt to merge identical constants across compilation units") },
1246 {"merge-all-constants", &flag_dummy, 2,
1247 N_("Attempt to merge identical constants and constant variables") },
1248 {"dump-unnumbered", &flag_dummy, 1,
1249 N_("Suppress output of instruction numbers and line number notes in debugging dumps") },
1250 {"instrument-functions", &flag_dummy, 1,
1251 N_("Instrument function entry/exit with profiling calls") },
1252 {"zero-initialized-in-bss", &flag_dummy, 1,
1253 N_("Put zero initialized data in the bss section") },
1254 {"ssa", &flag_dummy, 1,
1255 N_("Enable SSA optimizations") },
1256 {"ssa-ccp", &flag_dummy, 1,
1257 N_("Enable SSA conditional constant propagation") },
1258 {"ssa-dce", &flag_dummy, 1,
1259 N_("Enable aggressive SSA dead code elimination") },
1260 {"leading-underscore", &flag_dummy, 1,
1261 N_("External symbols have a leading underscore") },
1262 {"ident", &flag_dummy, 0,
1263 N_("Process #ident directives") },
1264 { "peephole2", &flag_dummy, 1,
1265 N_("Enables an rtl peephole pass run before sched2") },
1266 {"finite-math-only", &flag_dummy, 1,
1267 N_("Assume no NaNs or +-Infs are generated") },
1268 { "guess-branch-probability", &flag_dummy, 1,
1269 N_("Enables guessing of branch probabilities") },
1270 {"math-errno", &flag_dummy, 1,
1271 N_("Set errno after built-in math functions") },
1272 {"trapping-math", &flag_dummy, 1,
1273 N_("Floating-point operations can trap") },
1274 {"unsafe-math-optimizations", &flag_dummy, 1,
1275 N_("Allow math optimizations that may violate IEEE or ANSI standards") },
1276 {"signaling-nans", &flag_dummy, 1,
1277 N_("Disable optimizations observable by IEEE signaling NaNs") },
1278 {"bounds-check", &flag_dummy, 1,
1279 N_("Generate code to check bounds before indexing arrays") },
1280 {"single-precision-constant", &flag_dummy, 1,
1281 N_("Convert floating point constant to single precision constant") },
1282 {"time-report", &flag_dummy, 1,
1283 N_("Report time taken by each compiler pass at end of run") },
1284 {"mem-report", &flag_dummy, 1,
1285 N_("Report on permanent memory allocation at end of run") },
1286 { "trapv", &flag_dummy, 1,
1287 N_("Trap for signed overflow in addition / subtraction / multiplication") },
1288 { "wrapv", &flag_dummy, 1,
1289 N_("Assume signed arithmetic overflow wraps around") },
1290 { "new-ra", &flag_dummy, 1,
1291 N_("Use graph coloring register allocation.") },
1294 /* Table of language-specific options. */
1296 static const struct lang_opt
1298 const char *const option;
1299 const char *const description;
1301 documented_lang_options[] =
1303 /* In order not to overload the --help output, the convention
1304 used here is to only describe those options which are not
1305 enabled by default. */
1308 N_("Compile just for ISO C90") },
1310 N_("Determine language standard") },
1312 { "-fsigned-bitfields", "" },
1313 { "-funsigned-bitfields",
1314 N_("Make bit-fields by unsigned by default") },
1315 { "-fno-signed-bitfields", "" },
1316 { "-fno-unsigned-bitfields","" },
1318 N_("Make 'char' be signed by default") },
1319 { "-funsigned-char",
1320 N_("Make 'char' be unsigned by default") },
1321 { "-fno-signed-char", "" },
1322 { "-fno-unsigned-char", "" },
1326 N_("Do not recognize the 'asm' keyword") },
1327 { "-fbuiltin", "" },
1329 N_("Do not recognize any built in functions") },
1331 N_("Assume normal C execution environment") },
1332 { "-fno-hosted", "" },
1334 N_("Assume that standard libraries & main might not exist") },
1335 { "-fno-freestanding", "" },
1336 { "-fcond-mismatch",
1337 N_("Allow different types as args of ? operator") },
1338 { "-fno-cond-mismatch", "" },
1339 { "-fdollars-in-identifiers",
1340 N_("Allow the use of $ inside identifiers") },
1341 { "-fno-dollars-in-identifiers", "" },
1342 { "-fpreprocessed", "" },
1343 { "-fno-preprocessed", "" },
1345 N_("Use the same size for double as for float") },
1346 { "-fno-short-double", "" },
1348 N_("Use the smallest fitting integer to hold enums") },
1349 { "-fno-short-enums", "" },
1351 N_("Override the underlying type for wchar_t to `unsigned short'") },
1352 { "-fno-short-wchar", "" },
1355 N_("Enable most warning messages") },
1356 { "-Wbad-function-cast",
1357 N_("Warn about casting functions to incompatible types") },
1358 { "-Wno-bad-function-cast", "" },
1359 { "-Wmissing-format-attribute",
1360 N_("Warn about functions which might be candidates for format attributes") },
1361 { "-Wno-missing-format-attribute", "" },
1363 N_("Warn about casts which discard qualifiers") },
1364 { "-Wno-cast-qual", "" },
1365 { "-Wchar-subscripts",
1366 N_("Warn about subscripts whose type is 'char'") },
1367 { "-Wno-char-subscripts", "" },
1369 N_("Warn if nested comments are detected") },
1370 { "-Wno-comment", "" },
1372 N_("Warn if nested comments are detected") },
1373 { "-Wno-comments", "" },
1375 N_("Warn about possibly confusing type conversions") },
1376 { "-Wno-conversion", "" },
1377 { "-Wdiv-by-zero", "" },
1378 { "-Wno-div-by-zero",
1379 N_("Do not warn about compile-time integer division by zero") },
1381 N_("Warn about testing equality of floating point numbers") },
1382 { "-Wno-float-equal", "" },
1384 N_("Warn about printf/scanf/strftime/strfmon format anomalies") },
1385 { "-Wno-format", "" },
1386 { "-Wformat-extra-args", "" },
1387 { "-Wno-format-extra-args",
1388 N_("Don't warn about too many arguments to format functions") },
1389 { "-Wformat-nonliteral",
1390 N_("Warn about non-string-literal format strings") },
1391 { "-Wno-format-nonliteral", "" },
1392 { "-Wformat-security",
1393 N_("Warn about possible security problems with format functions") },
1394 { "-Wno-format-security", "" },
1395 { "-Wformat-y2k", "" },
1396 { "-Wno-format-y2k",
1397 N_("Don't warn about strftime formats yielding 2 digit years") },
1398 { "-Wimplicit-function-declaration",
1399 N_("Warn about implicit function declarations") },
1400 { "-Wno-implicit-function-declaration", "" },
1401 { "-Werror-implicit-function-declaration", "" },
1403 N_("Warn when a declaration does not specify a type") },
1404 { "-Wno-implicit-int", "" },
1405 { "-Wimplicit", "" },
1406 { "-Wno-implicit", "" },
1408 N_("Warn about the use of the #import directive") },
1409 { "-Wno-import", "" },
1411 N_("Warn about PCH files that are found but not used") },
1412 { "-Wlong-long","" },
1414 N_("Do not warn about using 'long long' when -pedantic") },
1416 N_("Warn about suspicious declarations of main") },
1417 { "-Wno-main", "" },
1418 { "-Wmissing-braces",
1419 N_("Warn about possibly missing braces around initializers") },
1420 { "-Wno-missing-braces", "" },
1421 { "-Wmissing-declarations",
1422 N_("Warn about global funcs without previous declarations") },
1423 { "-Wno-missing-declarations", "" },
1424 { "-Wmissing-prototypes",
1425 N_("Warn about global funcs without prototypes") },
1426 { "-Wno-missing-prototypes", "" },
1428 N_("Warn about use of multicharacter literals") },
1429 { "-Wno-multichar", "" },
1430 { "-Wnested-externs",
1431 N_("Warn about externs not at file scope level") },
1432 { "-Wno-nested-externs", "" },
1434 N_("Warn about possible missing parentheses") },
1435 { "-Wno-parentheses", "" },
1436 { "-Wpointer-arith",
1437 N_("Warn about function pointer arithmetic") },
1438 { "-Wno-pointer-arith", "" },
1439 { "-Wredundant-decls",
1440 N_("Warn about multiple declarations of the same object") },
1441 { "-Wno-redundant-decls", "" },
1443 N_("Warn whenever a function's return-type defaults to int") },
1444 { "-Wno-return-type", "" },
1445 { "-Wsequence-point",
1446 N_("Warn about possible violations of sequence point rules") },
1447 { "-Wno-sequence-point", "" },
1449 N_("Warn about signed/unsigned comparisons") },
1450 { "-Wno-sign-compare", "" },
1451 { "-Wstrict-prototypes",
1452 N_("Warn about non-prototyped function decls") },
1453 { "-Wno-strict-prototypes", "" },
1455 N_("Warn about constructs whose meanings change in ISO C") },
1456 { "-Wno-traditional", "" },
1458 N_("Warn when trigraphs are encountered") },
1459 { "-Wno-trigraphs", "" },
1461 { "-Wno-undef", "" },
1462 { "-Wunknown-pragmas",
1463 N_("Warn about unrecognized pragmas") },
1464 { "-Wno-unknown-pragmas", "" },
1465 { "-Wwrite-strings",
1466 N_("Mark strings as 'const char *'") },
1467 { "-Wno-write-strings", "" },
1469 #define DEFINE_LANG_NAME(NAME) { NULL, NAME },
1471 #include "options_.h"
1475 /* Here is a table, controlled by the tm.h file, listing each -m switch
1476 and which bits in `target_switches' it should set or clear.
1477 If VALUE is positive, it is bits to set.
1478 If VALUE is negative, -VALUE is bits to clear.
1479 (The sign bit is not used so there is no confusion.) */
1483 const char *const name;
1485 const char *const description;
1487 target_switches[] = TARGET_SWITCHES;
1489 /* This table is similar, but allows the switch to have a value. */
1491 #ifdef TARGET_OPTIONS
1494 const char *const prefix;
1495 const char **const variable;
1496 const char *const description;
1497 const char *const value;
1499 target_options[] = TARGET_OPTIONS;
1502 /* Options controlling warnings. */
1504 /* Nonzero means warn about function definitions that default the return type
1505 or that use a null return and have a return-type other than void. */
1507 int warn_return_type;
1509 /* Used for the -W options array temporarily. */
1510 static int warn_dummy;
1512 /* Like f_options, but for -W. */
1514 static const lang_independent_options W_options[] =
1516 {"unused-function", &warn_dummy, 1,
1517 N_("Warn when a function is unused") },
1518 {"unused-label", &warn_dummy, 1,
1519 N_("Warn when a label is unused") },
1520 {"unused-parameter", &warn_dummy, 1,
1521 N_("Warn when a function parameter is unused") },
1522 {"unused-variable", &warn_dummy, 1,
1523 N_("Warn when a variable is unused") },
1524 {"unused-value", &warn_dummy, 1,
1525 N_("Warn when an expression value is unused") },
1526 {"system-headers", &warn_dummy, 1,
1527 N_("Do not suppress warnings from system headers") },
1528 {"error", &warn_dummy, 1,
1529 N_("Treat all warnings as errors") },
1530 {"shadow", &warn_dummy, 1,
1531 N_("Warn when one local variable shadows another") },
1532 {"switch", &warn_dummy, 1,
1533 N_("Warn about enumerated switches, with no default, missing a case") },
1534 {"switch-default", &warn_dummy, 1,
1535 N_("Warn about enumerated switches missing a default case") },
1536 {"switch-enum", &warn_dummy, 1,
1537 N_("Warn about all enumerated switches missing a specific case") },
1538 {"aggregate-return", &warn_dummy, 1,
1539 N_("Warn about returning structures, unions or arrays") },
1540 {"cast-align", &warn_dummy, 1,
1541 N_("Warn about pointer casts which increase alignment") },
1542 {"unreachable-code", &warn_dummy, 1,
1543 N_("Warn about code that will never be executed") },
1544 {"uninitialized", &warn_dummy, 1,
1545 N_("Warn about uninitialized automatic variables") },
1546 {"inline", &warn_dummy, 1,
1547 N_("Warn when an inlined function cannot be inlined") },
1548 {"packed", &warn_dummy, 1,
1549 N_("Warn when the packed attribute has no effect on struct layout") },
1550 {"padded", &warn_dummy, 1,
1551 N_("Warn when padding is required to align struct members") },
1552 {"disabled-optimization", &warn_dummy, 1,
1553 N_("Warn when an optimization pass is disabled") },
1554 {"deprecated-declarations", &warn_dummy, 1,
1555 N_("Warn about uses of __attribute__((deprecated)) declarations") },
1556 {"missing-noreturn", &warn_dummy, 1,
1557 N_("Warn about functions which might be candidates for attribute noreturn") },
1558 {"strict-aliasing", &warn_dummy, 1,
1559 N_ ("Warn about code which might break the strict aliasing rules") }
1562 /* Output files for assembler code (real compiler output)
1563 and debugging dumps. */
1566 FILE *aux_info_file;
1567 FILE *rtl_dump_file = NULL;
1569 /* Decode the string P as an integral parameter.
1570 If the string is indeed an integer return its numeric value else
1571 issue an Invalid Option error for the option PNAME and return DEFVAL.
1572 If PNAME is zero just return DEFVAL, do not call error. */
1575 read_integral_parameter (const char *p, const char *pname, const int defval)
1577 const char *endp = p;
1581 if (ISDIGIT (*endp))
1590 error ("invalid option argument `%s'", pname);
1597 /* Return the logarithm of X, base 2, considering X unsigned,
1598 if X is a power of 2. Otherwise, returns -1.
1600 This should be used via the `exact_log2' macro. */
1603 exact_log2_wide (unsigned HOST_WIDE_INT x)
1606 /* Test for 0 or a power of 2. */
1607 if (x == 0 || x != (x & -x))
1609 while ((x >>= 1) != 0)
1614 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1615 If X is 0, return -1.
1617 This should be used via the floor_log2 macro. */
1620 floor_log2_wide (unsigned HOST_WIDE_INT x)
1629 /* Handler for fatal signals, such as SIGSEGV. These are transformed
1630 into ICE messages, which is much more user friendly. In case the
1631 error printer crashes, reset the signal to prevent infinite recursion. */
1634 crash_signal (int signo)
1636 signal (signo, SIG_DFL);
1637 internal_error ("%s", strsignal (signo));
1640 /* Arrange to dump core on error. (The regular error message is still
1641 printed first, except in the case of abort().) */
1644 setup_core_dumping (void)
1647 signal (SIGABRT, SIG_DFL);
1649 #if defined(HAVE_SETRLIMIT)
1652 if (getrlimit (RLIMIT_CORE, &rlim) != 0)
1653 fatal_error ("getting core file size maximum limit: %m");
1654 rlim.rlim_cur = rlim.rlim_max;
1655 if (setrlimit (RLIMIT_CORE, &rlim) != 0)
1656 fatal_error ("setting core file size limit to maximum: %m");
1659 diagnostic_abort_on_error (global_dc);
1663 /* Strip off a legitimate source ending from the input string NAME of
1664 length LEN. Rather than having to know the names used by all of
1665 our front ends, we strip off an ending of a period followed by
1666 up to five characters. (Java uses ".class".) */
1669 strip_off_ending (char *name, int len)
1672 for (i = 2; i < 6 && len > i; i++)
1674 if (name[len - i] == '.')
1676 name[len - i] = '\0';
1682 /* Output a quoted string. */
1685 output_quoted_string (FILE *asm_file, const char *string)
1687 #ifdef OUTPUT_QUOTED_STRING
1688 OUTPUT_QUOTED_STRING (asm_file, string);
1692 putc ('\"', asm_file);
1693 while ((c = *string++) != 0)
1697 if (c == '\"' || c == '\\')
1698 putc ('\\', asm_file);
1702 fprintf (asm_file, "\\%03o", (unsigned char) c);
1704 putc ('\"', asm_file);
1708 /* Output NAME into FILE after having turned it into something
1709 usable as an identifier in a target's assembly file. */
1711 output_clean_symbol_name (FILE *file, const char *name)
1713 /* Make a copy of NAME. */
1714 char *id = xstrdup (name);
1716 /* Make it look like a valid identifier for an assembler. */
1717 clean_symbol_name (id);
1724 /* Output a file name in the form wanted by System V. */
1727 output_file_directive (FILE *asm_file, const char *input_name)
1729 int len = strlen (input_name);
1730 const char *na = input_name + len;
1732 /* NA gets INPUT_NAME sans directory names. */
1733 while (na > input_name)
1735 if (IS_DIR_SEPARATOR (na[-1]))
1740 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1741 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
1743 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1744 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1746 fprintf (asm_file, "\t.file\t");
1747 output_quoted_string (asm_file, na);
1748 fputc ('\n', asm_file);
1753 /* Routine to open a dump file. Return true if the dump file is enabled. */
1756 open_dump_file (enum dump_file_index index, tree decl)
1759 const char *open_arg;
1762 if (! dump_file[index].enabled)
1765 timevar_push (TV_DUMP);
1766 if (rtl_dump_file != NULL)
1767 fclose (rtl_dump_file);
1769 sprintf (seq, DUMPFILE_FORMAT, index);
1771 if (! dump_file[index].initialized)
1773 /* If we've not initialized the files, do so now. */
1774 if (graph_dump_format != no_graph
1775 && dump_file[index].graph_dump_p)
1777 dump_name = concat (seq, dump_file[index].extension, NULL);
1778 clean_graph_dump_file (dump_base_name, dump_name);
1781 dump_file[index].initialized = 1;
1787 dump_name = concat (dump_base_name, seq,
1788 dump_file[index].extension, NULL);
1790 rtl_dump_file = fopen (dump_name, open_arg);
1791 if (rtl_dump_file == NULL)
1792 fatal_error ("can't open %s: %m", dump_name);
1797 fprintf (rtl_dump_file, "\n;; Function %s%s\n\n",
1798 (*lang_hooks.decl_printable_name) (decl, 2),
1799 cfun->function_frequency == FUNCTION_FREQUENCY_HOT
1801 : cfun->function_frequency == FUNCTION_FREQUENCY_UNLIKELY_EXECUTED
1802 ? " (unlikely executed)"
1805 timevar_pop (TV_DUMP);
1809 /* Routine to close a dump file. */
1812 close_dump_file (enum dump_file_index index,
1813 void (*func) (FILE *, rtx),
1816 if (! rtl_dump_file)
1819 timevar_push (TV_DUMP);
1821 && graph_dump_format != no_graph
1822 && dump_file[index].graph_dump_p)
1827 sprintf (seq, DUMPFILE_FORMAT, index);
1828 suffix = concat (seq, dump_file[index].extension, NULL);
1829 print_rtl_graph_with_bb (dump_base_name, suffix, insns);
1834 func (rtl_dump_file, insns);
1836 fflush (rtl_dump_file);
1837 fclose (rtl_dump_file);
1839 rtl_dump_file = NULL;
1840 timevar_pop (TV_DUMP);
1843 /* Do any final processing required for the declarations in VEC, of
1844 which there are LEN. We write out inline functions and variables
1845 that have been deferred until this point, but which are required.
1846 Returns nonzero if anything was put out. */
1849 wrapup_global_declarations (tree *vec, int len)
1854 int output_something = 0;
1856 for (i = 0; i < len; i++)
1860 /* We're not deferring this any longer. Assignment is
1861 conditional to avoid needlessly dirtying PCH pages. */
1862 if (DECL_DEFER_OUTPUT (decl) != 0)
1863 DECL_DEFER_OUTPUT (decl) = 0;
1865 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0)
1866 (*lang_hooks.finish_incomplete_decl) (decl);
1869 /* Now emit any global variables or functions that we have been
1870 putting off. We need to loop in case one of the things emitted
1871 here references another one which comes earlier in the list. */
1875 for (i = 0; i < len; i++)
1879 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
1882 /* Don't write out static consts, unless we still need them.
1884 We also keep static consts if not optimizing (for debugging),
1885 unless the user specified -fno-keep-static-consts.
1886 ??? They might be better written into the debug information.
1887 This is possible when using DWARF.
1889 A language processor that wants static constants to be always
1890 written out (even if it is not used) is responsible for
1891 calling rest_of_decl_compilation itself. E.g. the C front-end
1892 calls rest_of_decl_compilation from finish_decl.
1893 One motivation for this is that is conventional in some
1894 environments to write things like:
1895 static const char rcsid[] = "... version string ...";
1896 intending to force the string to be in the executable.
1898 A language processor that would prefer to have unneeded
1899 static constants "optimized away" would just defer writing
1900 them out until here. E.g. C++ does this, because static
1901 constants are often defined in header files.
1903 ??? A tempting alternative (for both C and C++) would be
1904 to force a constant to be written if and only if it is
1905 defined in a main file, as opposed to an include file. */
1907 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl))
1911 if (flag_unit_at_a_time
1912 && cgraph_varpool_node (decl)->finalized)
1914 else if (flag_unit_at_a_time
1915 && (TREE_USED (decl)
1916 || TREE_USED (DECL_ASSEMBLER_NAME (decl))))
1918 else if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
1920 else if (DECL_COMDAT (decl))
1922 else if (TREE_READONLY (decl) && !TREE_PUBLIC (decl)
1923 && (optimize || !flag_keep_static_consts
1924 || DECL_ARTIFICIAL (decl)))
1930 rest_of_decl_compilation (decl, NULL, 1, 1);
1934 if (TREE_CODE (decl) == FUNCTION_DECL
1935 && DECL_INITIAL (decl) != 0
1936 && DECL_SAVED_INSNS (decl) != 0
1937 && (flag_keep_inline_functions
1938 || (TREE_PUBLIC (decl) && !DECL_COMDAT (decl))
1939 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
1942 output_inline_function (decl);
1947 output_something = 1;
1951 return output_something;
1954 /* Issue appropriate warnings for the global declarations in VEC (of
1955 which there are LEN). Output debugging information for them. */
1958 check_global_declarations (tree *vec, int len)
1963 for (i = 0; i < len; i++)
1967 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
1968 && ! TREE_ASM_WRITTEN (decl))
1969 /* Cancel the RTL for this decl so that, if debugging info
1970 output for global variables is still to come,
1971 this one will be omitted. */
1972 SET_DECL_RTL (decl, NULL_RTX);
1974 /* Warn about any function
1975 declared static but not defined.
1976 We don't warn about variables,
1977 because many programs have static variables
1978 that exist only to get some text into the object file. */
1979 if (TREE_CODE (decl) == FUNCTION_DECL
1980 && (warn_unused_function
1981 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
1982 && DECL_INITIAL (decl) == 0
1983 && DECL_EXTERNAL (decl)
1984 && ! DECL_ARTIFICIAL (decl)
1985 && ! TREE_PUBLIC (decl))
1987 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
1988 pedwarn_with_decl (decl,
1989 "`%s' used but never defined");
1991 warning_with_decl (decl,
1992 "`%s' declared `static' but never defined");
1993 /* This symbol is effectively an "extern" declaration now. */
1994 TREE_PUBLIC (decl) = 1;
1995 assemble_external (decl);
1998 /* Warn about static fns or vars defined but not used. */
1999 if (((warn_unused_function && TREE_CODE (decl) == FUNCTION_DECL)
2000 || (warn_unused_variable && TREE_CODE (decl) == VAR_DECL))
2001 && ! TREE_USED (decl)
2002 /* The TREE_USED bit for file-scope decls is kept in the identifier,
2003 to handle multiple external decls in different scopes. */
2004 && ! TREE_USED (DECL_NAME (decl))
2005 && ! DECL_EXTERNAL (decl)
2006 && ! TREE_PUBLIC (decl)
2007 /* A volatile variable might be used in some non-obvious way. */
2008 && ! TREE_THIS_VOLATILE (decl)
2009 /* Global register variables must be declared to reserve them. */
2010 && ! (TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl))
2011 /* Otherwise, ask the language. */
2012 && (*lang_hooks.decls.warn_unused_global) (decl))
2013 warning_with_decl (decl, "`%s' defined but not used");
2015 /* Avoid confusing the debug information machinery when there are
2017 if (errorcount == 0 && sorrycount == 0)
2019 timevar_push (TV_SYMOUT);
2020 (*debug_hooks->global_decl) (decl);
2021 timevar_pop (TV_SYMOUT);
2026 /* Save the current INPUT_LOCATION on the top entry in the
2027 INPUT_FILE_STACK. Push a new entry for FILE and LINE, and set the
2028 INPUT_LOCATION accordingly. */
2031 push_srcloc (const char *file, int line)
2033 struct file_stack *fs;
2035 fs = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2036 fs->location = input_location;
2037 fs->next = input_file_stack;
2038 input_filename = file;
2040 input_file_stack = fs;
2041 input_file_stack_tick++;
2044 /* Pop the top entry off the stack of presently open source files.
2045 Restore the INPUT_LOCATION from the new topmost entry on the
2051 struct file_stack *fs;
2053 fs = input_file_stack;
2054 input_location = fs->location;
2055 input_file_stack = fs->next;
2057 input_file_stack_tick++;
2060 /* Compile an entire translation unit. Write a file of assembly
2061 output and various debugging dumps. */
2066 /* Initialize yet another pass. */
2068 init_final (main_input_filename);
2069 coverage_init (aux_base_name);
2071 timevar_push (TV_PARSE);
2073 /* Call the parser, which parses the entire file (calling
2074 rest_of_compilation for each function). */
2075 (*lang_hooks.parse_file) (set_yydebug);
2077 /* In case there were missing block closers,
2078 get us back to the global binding level. */
2079 (*lang_hooks.clear_binding_stack) ();
2081 /* Compilation is now finished except for writing
2082 what's left of the symbol table output. */
2083 timevar_pop (TV_PARSE);
2085 if (flag_syntax_only)
2088 (*lang_hooks.decls.final_write_globals)();
2090 cgraph_varpool_assemble_pending_decls ();
2092 /* This must occur after the loop to output deferred functions.
2093 Else the coverage initializer would not be emitted if all the
2094 functions in this compilation unit were deferred. */
2097 /* Write out any pending weak symbol declarations. */
2101 /* Do dbx symbols. */
2102 timevar_push (TV_SYMOUT);
2104 #ifdef DWARF2_UNWIND_INFO
2105 if (dwarf2out_do_frame ())
2106 dwarf2out_frame_finish ();
2109 (*debug_hooks->finish) (main_input_filename);
2110 timevar_pop (TV_SYMOUT);
2112 /* Output some stuff at end of file if nec. */
2114 dw2_output_indirect_constants ();
2116 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
2118 timevar_push (TV_DUMP);
2119 open_dump_file (DFI_bp, NULL);
2123 close_dump_file (DFI_bp, NULL, NULL_RTX);
2124 timevar_pop (TV_DUMP);
2127 targetm.asm_out.file_end ();
2129 /* Attach a special .ident directive to the end of the file to identify
2130 the version of GCC which compiled this code. The format of the .ident
2131 string is patterned after the ones produced by native SVR4 compilers. */
2134 fprintf (asm_out_file, "%s\"GCC: (GNU) %s\"\n",
2135 IDENT_ASM_OP, version_string);
2138 if (optimize > 0 && open_dump_file (DFI_combine, NULL))
2140 timevar_push (TV_DUMP);
2141 dump_combine_total_stats (rtl_dump_file);
2142 close_dump_file (DFI_combine, NULL, NULL_RTX);
2143 timevar_pop (TV_DUMP);
2147 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2148 and TYPE_DECL nodes.
2150 This does nothing for local (non-static) variables, unless the
2151 variable is a register variable with an ASMSPEC. In that case, or
2152 if the variable is not an automatic, it sets up the RTL and
2153 outputs any assembler code (label definition, storage allocation
2154 and initialization).
2156 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2157 the assembler symbol name to be used. TOP_LEVEL is nonzero
2158 if this declaration is not within a function. */
2161 rest_of_decl_compilation (tree decl,
2162 const char *asmspec,
2166 /* We deferred calling assemble_alias so that we could collect
2167 other attributes such as visibility. Emit the alias now. */
2170 alias = lookup_attribute ("alias", DECL_ATTRIBUTES (decl));
2173 alias = TREE_VALUE (TREE_VALUE (alias));
2174 alias = get_identifier (TREE_STRING_POINTER (alias));
2175 assemble_alias (decl, alias);
2179 /* Forward declarations for nested functions are not "external",
2180 but we need to treat them as if they were. */
2181 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2182 || TREE_CODE (decl) == FUNCTION_DECL)
2184 timevar_push (TV_VARCONST);
2187 make_decl_rtl (decl, asmspec);
2189 /* Don't output anything when a tentative file-scope definition
2190 is seen. But at end of compilation, do output code for them. */
2191 if (at_end || !DECL_DEFER_OUTPUT (decl))
2193 if (flag_unit_at_a_time && TREE_CODE (decl) != FUNCTION_DECL
2195 cgraph_varpool_finalize_decl (decl);
2197 assemble_variable (decl, top_level, at_end, 0);
2200 #ifdef ASM_FINISH_DECLARE_OBJECT
2201 if (decl == last_assemble_variable_decl)
2203 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
2208 timevar_pop (TV_VARCONST);
2210 else if (DECL_REGISTER (decl) && asmspec != 0)
2212 if (decode_reg_name (asmspec) >= 0)
2214 SET_DECL_RTL (decl, NULL_RTX);
2215 make_decl_rtl (decl, asmspec);
2219 error ("invalid register name `%s' for register variable", asmspec);
2220 DECL_REGISTER (decl) = 0;
2225 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2226 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2227 && TREE_CODE (decl) == TYPE_DECL)
2229 timevar_push (TV_SYMOUT);
2230 dbxout_symbol (decl, 0);
2231 timevar_pop (TV_SYMOUT);
2234 #ifdef SDB_DEBUGGING_INFO
2235 else if (write_symbols == SDB_DEBUG && top_level
2236 && TREE_CODE (decl) == TYPE_DECL)
2238 timevar_push (TV_SYMOUT);
2239 sdbout_symbol (decl, 0);
2240 timevar_pop (TV_SYMOUT);
2243 #ifdef DWARF2_DEBUGGING_INFO
2244 else if ((write_symbols == DWARF2_DEBUG
2245 || write_symbols == VMS_AND_DWARF2_DEBUG)
2247 && TREE_CODE (decl) == TYPE_DECL)
2249 timevar_push (TV_SYMOUT);
2250 dwarf2out_decl (decl);
2251 timevar_pop (TV_SYMOUT);
2256 /* Called after finishing a record, union or enumeral type. */
2259 rest_of_type_compilation (
2260 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) \
2261 || defined (SDB_DEBUGGING_INFO) || defined (DWARF2_DEBUGGING_INFO)
2265 tree type ATTRIBUTE_UNUSED,
2266 int toplev ATTRIBUTE_UNUSED
2270 /* Avoid confusing the debug information machinery when there are
2272 if (errorcount != 0 || sorrycount != 0)
2275 timevar_push (TV_SYMOUT);
2276 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2277 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2278 dbxout_symbol (TYPE_STUB_DECL (type), !toplev);
2280 #ifdef SDB_DEBUGGING_INFO
2281 if (write_symbols == SDB_DEBUG)
2282 sdbout_symbol (TYPE_STUB_DECL (type), !toplev);
2284 #ifdef DWARF2_DEBUGGING_INFO
2285 if ((write_symbols == DWARF2_DEBUG
2286 || write_symbols == VMS_AND_DWARF2_DEBUG)
2288 dwarf2out_decl (TYPE_STUB_DECL (type));
2290 timevar_pop (TV_SYMOUT);
2293 /* Turn the RTL into assembly. */
2295 rest_of_handle_final (tree decl, rtx insns)
2297 timevar_push (TV_FINAL);
2302 /* Get the function's name, as described by its RTL. This may be
2303 different from the DECL_NAME name used in the source file. */
2305 x = DECL_RTL (decl);
2306 if (GET_CODE (x) != MEM)
2309 if (GET_CODE (x) != SYMBOL_REF)
2311 fnname = XSTR (x, 0);
2313 assemble_start_function (decl, fnname);
2314 final_start_function (insns, asm_out_file, optimize);
2315 final (insns, asm_out_file, optimize, 0);
2316 final_end_function ();
2318 #ifdef IA64_UNWIND_INFO
2319 /* ??? The IA-64 ".handlerdata" directive must be issued before
2320 the ".endp" directive that closes the procedure descriptor. */
2321 output_function_exception_table ();
2324 assemble_end_function (decl, fnname);
2326 #ifndef IA64_UNWIND_INFO
2327 /* Otherwise, it feels unclean to switch sections in the middle. */
2328 output_function_exception_table ();
2332 fflush (asm_out_file);
2334 /* Release all memory allocated by flow. */
2335 free_basic_block_vars (0);
2337 /* Release all memory held by regsets now. */
2338 regset_release_memory ();
2340 timevar_pop (TV_FINAL);
2346 /* Run delay slot optimization. */
2348 rest_of_handle_delay_slots (tree decl, rtx insns)
2350 timevar_push (TV_DBR_SCHED);
2351 open_dump_file (DFI_dbr, decl);
2353 dbr_schedule (insns, rtl_dump_file);
2355 close_dump_file (DFI_dbr, print_rtl, insns);
2356 timevar_pop (TV_DBR_SCHED);
2363 /* Convert register usage from flat register file usage to a stack
2366 rest_of_handle_stack_regs (tree decl, rtx insns)
2368 timevar_push (TV_REG_STACK);
2369 open_dump_file (DFI_stack, decl);
2371 if (reg_to_stack (insns, rtl_dump_file) && optimize)
2373 if (cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK
2374 | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0))
2375 && flag_reorder_blocks)
2377 reorder_basic_blocks ();
2378 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK);
2382 close_dump_file (DFI_stack, print_rtl_with_bb, insns);
2383 timevar_pop (TV_REG_STACK);
2390 /* Machine independent reorg pass. */
2392 rest_of_handle_machine_reorg (tree decl, rtx insns)
2394 timevar_push (TV_MACH_DEP);
2395 open_dump_file (DFI_mach, decl);
2397 (*targetm.machine_dependent_reorg) ();
2399 close_dump_file (DFI_mach, print_rtl, insns);
2400 timevar_pop (TV_MACH_DEP);
2406 /* Run new register allocator. Return TRUE if we must exit
2407 rest_of_compilation upon return. */
2409 rest_of_handle_new_regalloc (tree decl, rtx insns, int *rebuild_notes)
2413 delete_trivially_dead_insns (insns, max_reg_num ());
2416 timevar_pop (TV_LOCAL_ALLOC);
2417 if (dump_file[DFI_lreg].enabled)
2419 timevar_push (TV_DUMP);
2421 close_dump_file (DFI_lreg, NULL, NULL);
2422 timevar_pop (TV_DUMP);
2425 /* XXX clean up the whole mess to bring live info in shape again. */
2426 timevar_push (TV_GLOBAL_ALLOC);
2427 open_dump_file (DFI_greg, decl);
2429 build_insn_chain (insns);
2430 failure = reload (insns, 0);
2432 timevar_pop (TV_GLOBAL_ALLOC);
2434 if (dump_file[DFI_greg].enabled)
2436 timevar_push (TV_DUMP);
2438 dump_global_regs (rtl_dump_file);
2440 close_dump_file (DFI_greg, print_rtl_with_bb, insns);
2441 timevar_pop (TV_DUMP);
2447 reload_completed = 1;
2453 /* Run old register allocator. Return TRUE if we must exit
2454 rest_of_compilation upon return. */
2456 rest_of_handle_old_regalloc (tree decl, rtx insns, int *rebuild_notes)
2460 /* Allocate the reg_renumber array. */
2461 allocate_reg_info (max_regno, FALSE, TRUE);
2463 /* And the reg_equiv_memory_loc array. */
2464 reg_equiv_memory_loc = (rtx *) xcalloc (max_regno, sizeof (rtx));
2466 allocate_initial_values (reg_equiv_memory_loc);
2468 regclass (insns, max_reg_num (), rtl_dump_file);
2469 *rebuild_notes = local_alloc ();
2471 timevar_pop (TV_LOCAL_ALLOC);
2473 if (dump_file[DFI_lreg].enabled)
2475 timevar_push (TV_DUMP);
2477 dump_flow_info (rtl_dump_file);
2478 dump_local_alloc (rtl_dump_file);
2480 close_dump_file (DFI_lreg, print_rtl_with_bb, insns);
2481 timevar_pop (TV_DUMP);
2486 timevar_push (TV_GLOBAL_ALLOC);
2487 open_dump_file (DFI_greg, decl);
2489 /* If optimizing, allocate remaining pseudo-regs. Do the reload
2490 pass fixing up any insns that are invalid. */
2493 failure = global_alloc (rtl_dump_file);
2496 build_insn_chain (insns);
2497 failure = reload (insns, 0);
2500 timevar_pop (TV_GLOBAL_ALLOC);
2502 if (dump_file[DFI_greg].enabled)
2504 timevar_push (TV_DUMP);
2506 dump_global_regs (rtl_dump_file);
2508 close_dump_file (DFI_greg, print_rtl_with_bb, insns);
2509 timevar_pop (TV_DUMP);
2515 /* Run the regrename and cprop passes. */
2517 rest_of_handle_regrename (tree decl, rtx insns)
2519 timevar_push (TV_RENAME_REGISTERS);
2520 open_dump_file (DFI_rnreg, decl);
2522 if (flag_rename_registers)
2523 regrename_optimize ();
2524 if (flag_cprop_registers)
2525 copyprop_hardreg_forward ();
2527 close_dump_file (DFI_rnreg, print_rtl_with_bb, insns);
2528 timevar_pop (TV_RENAME_REGISTERS);
2531 /* Reorder basic blocks. */
2533 rest_of_handle_reorder_blocks (tree decl, rtx insns)
2535 timevar_push (TV_REORDER_BLOCKS);
2536 open_dump_file (DFI_bbro, decl);
2538 /* Last attempt to optimize CFG, as scheduling, peepholing and insn
2539 splitting possibly introduced more crossjumping opportunities. */
2540 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE
2541 | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0));
2543 if (flag_sched2_use_traces && flag_schedule_insns_after_reload)
2545 if (flag_reorder_blocks)
2546 reorder_basic_blocks ();
2547 if (flag_reorder_blocks
2548 || (flag_sched2_use_traces && flag_schedule_insns_after_reload))
2549 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
2551 close_dump_file (DFI_bbro, print_rtl_with_bb, insns);
2552 timevar_pop (TV_REORDER_BLOCKS);
2555 #ifdef INSN_SCHEDULING
2556 /* Run instruction scheduler. */
2558 rest_of_handle_sched (tree decl, rtx insns)
2560 timevar_push (TV_SCHED);
2562 /* Print function header into sched dump now
2563 because doing the sched analysis makes some of the dump. */
2564 if (optimize > 0 && flag_schedule_insns)
2566 open_dump_file (DFI_sched, decl);
2568 /* Do control and data sched analysis,
2569 and write some of the results to dump file. */
2571 schedule_insns (rtl_dump_file);
2573 close_dump_file (DFI_sched, print_rtl_with_bb, insns);
2575 timevar_pop (TV_SCHED);
2580 /* Run second scheduling pass after reload. */
2582 rest_of_handle_sched2 (tree decl, rtx insns)
2584 timevar_push (TV_SCHED2);
2585 open_dump_file (DFI_sched2, decl);
2587 /* Do control and data sched analysis again,
2588 and write some more of the results to dump file. */
2590 split_all_insns (1);
2592 if (flag_sched2_use_superblocks || flag_sched2_use_traces)
2594 schedule_ebbs (rtl_dump_file);
2595 /* No liveness updating code yet, but it should be easy to do.
2596 reg-stack recompute the liveness when needed for now. */
2597 count_or_remove_death_notes (NULL, 1);
2598 cleanup_cfg (CLEANUP_EXPENSIVE);
2601 schedule_insns (rtl_dump_file);
2603 close_dump_file (DFI_sched2, print_rtl_with_bb, insns);
2604 timevar_pop (TV_SCHED2);
2610 /* Register allocation pre-pass, to reduce number of moves necessary
2611 for two-address machines. */
2613 rest_of_handle_regmove (tree decl, rtx insns)
2615 timevar_push (TV_REGMOVE);
2616 open_dump_file (DFI_regmove, decl);
2618 regmove_optimize (insns, max_reg_num (), rtl_dump_file);
2620 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
2621 close_dump_file (DFI_regmove, print_rtl_with_bb, insns);
2622 timevar_pop (TV_REGMOVE);
2629 rest_of_handle_tracer (tree decl, rtx insns)
2631 timevar_push (TV_TRACER);
2632 open_dump_file (DFI_tracer, decl);
2634 dump_flow_info (rtl_dump_file);
2636 cleanup_cfg (CLEANUP_EXPENSIVE);
2637 reg_scan (insns, max_reg_num (), 0);
2638 close_dump_file (DFI_tracer, print_rtl_with_bb, get_insns ());
2639 timevar_pop (TV_TRACER);
2642 /* If-conversion and CFG cleanup. */
2644 rest_of_handle_if_conversion (tree decl, rtx insns)
2646 open_dump_file (DFI_ce1, decl);
2647 if (flag_if_conversion)
2649 timevar_push (TV_IFCVT);
2651 dump_flow_info (rtl_dump_file);
2652 cleanup_cfg (CLEANUP_EXPENSIVE);
2653 reg_scan (insns, max_reg_num (), 0);
2655 timevar_pop (TV_IFCVT);
2657 timevar_push (TV_JUMP);
2658 cleanup_cfg (CLEANUP_EXPENSIVE);
2659 reg_scan (insns, max_reg_num (), 0);
2660 timevar_pop (TV_JUMP);
2661 close_dump_file (DFI_ce1, print_rtl_with_bb, get_insns ());
2664 /* Rerun if-conversion, as combine may have simplified things enough
2665 to now meet sequence length restrictions. */
2667 rest_of_handle_if_after_combine (tree decl, rtx insns)
2669 timevar_push (TV_IFCVT);
2670 open_dump_file (DFI_ce2, decl);
2676 close_dump_file (DFI_ce2, print_rtl_with_bb, insns);
2677 timevar_pop (TV_IFCVT);
2680 /* Do branch profiling and static profile estimation passes. */
2682 rest_of_handle_branch_prob (tree decl, rtx insns)
2686 timevar_push (TV_BRANCH_PROB);
2687 open_dump_file (DFI_bp, decl);
2688 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
2691 /* Discover and record the loop depth at the head of each basic
2692 block. The loop infrastructure does the real job for us. */
2693 flow_loops_find (&loops, LOOP_TREE);
2696 flow_loops_dump (&loops, rtl_dump_file, NULL, 0);
2698 /* Estimate using heuristics if no profiling info is available. */
2699 if (flag_guess_branch_prob)
2700 estimate_probability (&loops);
2702 flow_loops_free (&loops);
2703 close_dump_file (DFI_bp, print_rtl_with_bb, insns);
2704 timevar_pop (TV_BRANCH_PROB);
2707 /* Do control and data flow analysis; write some of the results to the
2710 rest_of_handle_cfg (tree decl, rtx insns)
2712 open_dump_file (DFI_cfg, decl);
2714 dump_flow_info (rtl_dump_file);
2716 cleanup_cfg (CLEANUP_EXPENSIVE
2717 | (flag_thread_jumps ? CLEANUP_THREADING : 0));
2719 /* It may make more sense to mark constant functions after dead code is
2720 eliminated by life_analysis, but we need to do it early, as -fprofile-arcs
2721 may insert code making function non-constant, but we still must consider
2722 it as constant, otherwise -fbranch-probabilities will not read data back.
2724 life_analysis rarely eliminates modification of external memory.
2727 mark_constant_function ();
2729 close_dump_file (DFI_cfg, print_rtl_with_bb, insns);
2732 /* Purge addressofs. */
2734 rest_of_handle_addresof (tree decl, rtx insns)
2736 open_dump_file (DFI_addressof, decl);
2738 purge_addressof (insns);
2740 purge_all_dead_edges (0);
2741 reg_scan (insns, max_reg_num (), 1);
2743 close_dump_file (DFI_addressof, print_rtl, insns);
2746 /* We may have potential sibling or tail recursion sites. Select one
2747 (of possibly multiple) methods of performing the call. */
2749 rest_of_handle_sibling_calls (rtx insns)
2752 optimize_sibling_and_tail_recursive_calls ();
2754 /* Recompute the CFG as sibling optimization clobbers it randomly. */
2755 free_bb_for_insn ();
2756 find_exception_handler_labels ();
2757 rebuild_jump_labels (insns);
2758 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2760 /* There is pass ordering problem - we must lower NOTE_INSN_PREDICTION
2761 notes before simplifying cfg and we must do lowering after sibcall
2762 that unhides parts of RTL chain and cleans up the CFG.
2764 Until sibcall is replaced by tree-level optimizer, lets just
2765 sweep away the NOTE_INSN_PREDICTION notes that leaked out. */
2766 for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
2767 if (GET_CODE (insn) == NOTE
2768 && NOTE_LINE_NUMBER (insn) == NOTE_INSN_PREDICTION)
2771 close_dump_file (DFI_sibling, print_rtl, get_insns ());
2774 /* Perform jump bypassing and control flow optimizations. */
2776 rest_of_handle_jump_bypass (tree decl, rtx insns)
2778 timevar_push (TV_BYPASS);
2779 open_dump_file (DFI_bypass, decl);
2781 cleanup_cfg (CLEANUP_EXPENSIVE);
2783 if (bypass_jumps (rtl_dump_file))
2785 rebuild_jump_labels (insns);
2786 cleanup_cfg (CLEANUP_EXPENSIVE);
2787 delete_trivially_dead_insns (insns, max_reg_num ());
2790 close_dump_file (DFI_bypass, print_rtl_with_bb, insns);
2791 timevar_pop (TV_BYPASS);
2795 #ifdef ENABLE_CHECKING
2796 verify_flow_info ();
2800 /* Handle inlining of functions in rest_of_compilation. Return TRUE
2801 if we must exit rest_of_compilation upon return. */
2803 rest_of_handle_inlining (tree decl)
2810 /* If we are reconsidering an inline function at the end of
2811 compilation, skip the stuff for making it inline. */
2812 if (DECL_SAVED_INSNS (decl) != 0)
2815 /* If this is nested inside an inlined external function, pretend
2816 it was only declared. Since we cannot inline such functions,
2817 generating code for this one is not only not necessary but will
2818 confuse some debugging output writers. */
2819 for (parent = DECL_CONTEXT (current_function_decl);
2820 parent != NULL_TREE;
2821 parent = get_containing_scope (parent))
2822 if (TREE_CODE (parent) == FUNCTION_DECL
2823 && DECL_INLINE (parent) && DECL_EXTERNAL (parent))
2825 DECL_INITIAL (decl) = 0;
2828 else if (TYPE_P (parent))
2829 /* A function in a local class should be treated normally. */
2832 /* If requested, consider whether to make this function inline. */
2833 if ((DECL_INLINE (decl) && !flag_no_inline)
2834 || flag_inline_functions)
2836 timevar_push (TV_INTEGRATION);
2837 lose = function_cannot_inline_p (decl);
2838 timevar_pop (TV_INTEGRATION);
2839 if (lose || ! optimize)
2841 if (warn_inline && DECL_INLINE (decl))
2842 warning_with_decl (decl, lose);
2843 DECL_ABSTRACT_ORIGIN (decl) = 0;
2844 /* Don't really compile an extern inline function.
2845 If we can't make it inline, pretend
2846 it was only declared. */
2847 if (DECL_EXTERNAL (decl))
2849 DECL_INITIAL (decl) = 0;
2854 /* ??? Note that we used to just make it look like if
2855 the "inline" keyword was specified when we decide
2856 to inline it (because of -finline-functions).
2857 garloff@suse.de, 2002-04-24: Add another flag to
2858 actually record this piece of information. */
2859 if (!DECL_INLINE (decl))
2860 DID_INLINE_FUNC (decl) = 1;
2861 inlinable = DECL_INLINE (decl) = 1;
2865 insns = get_insns ();
2867 /* Dump the rtl code if we are dumping rtl. */
2869 if (open_dump_file (DFI_rtl, decl))
2871 if (DECL_SAVED_INSNS (decl))
2872 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2873 close_dump_file (DFI_rtl, print_rtl, insns);
2876 /* Convert from NOTE_INSN_EH_REGION style notes, and do other
2877 sorts of eh initialization. Delay this until after the
2878 initial rtl dump so that we can see the original nesting. */
2879 convert_from_eh_region_ranges ();
2881 /* If function is inline, and we don't yet know whether to
2882 compile it by itself, defer decision till end of compilation.
2883 wrapup_global_declarations will (indirectly) call
2884 rest_of_compilation again for those functions that need to
2885 be output. Also defer those functions that we are supposed
2889 || (DECL_INLINE (decl)
2890 && flag_inline_functions
2891 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2892 && ! TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))
2893 && ! flag_keep_inline_functions)
2894 || DECL_EXTERNAL (decl))))
2895 DECL_DEFER_OUTPUT (decl) = 1;
2897 if (DECL_INLINE (decl))
2898 /* DWARF wants separate debugging info for abstract and
2899 concrete instances of all inline functions, including those
2900 declared inline but not inlined, and those inlined even
2901 though they weren't declared inline. Conveniently, that's
2902 what DECL_INLINE means at this point. */
2903 (*debug_hooks->deferred_inline_function) (decl);
2905 if (DECL_DEFER_OUTPUT (decl))
2907 /* If -Wreturn-type, we have to do a bit of compilation. We just
2908 want to call cleanup the cfg to figure out whether or not we can
2909 fall off the end of the function; we do the minimum amount of
2910 work necessary to make that safe. */
2911 if (warn_return_type)
2913 int saved_optimize = optimize;
2916 rebuild_jump_labels (insns);
2917 find_exception_handler_labels ();
2918 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2919 cleanup_cfg (CLEANUP_PRE_SIBCALL | CLEANUP_PRE_LOOP);
2920 optimize = saved_optimize;
2922 /* CFG is no longer maintained up-to-date. */
2923 free_bb_for_insn ();
2926 set_nothrow_function_flags ();
2927 if (current_function_nothrow)
2928 /* Now we know that this can't throw; set the flag for the benefit
2929 of other functions later in this translation unit. */
2930 TREE_NOTHROW (current_function_decl) = 1;
2932 timevar_push (TV_INTEGRATION);
2933 save_for_inline (decl);
2934 timevar_pop (TV_INTEGRATION);
2935 DECL_SAVED_INSNS (decl)->inlinable = inlinable;
2939 /* If specified extern inline but we aren't inlining it, we are
2940 done. This goes for anything that gets here with DECL_EXTERNAL
2941 set, not just things with DECL_INLINE. */
2942 return (bool) DECL_EXTERNAL (decl);
2945 /* Rest of compilation helper to convert the rtl to SSA form. */
2947 rest_of_handle_ssa (tree decl, rtx insns)
2949 timevar_push (TV_TO_SSA);
2950 open_dump_file (DFI_ssa, decl);
2952 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2955 close_dump_file (DFI_ssa, print_rtl_with_bb, insns);
2956 timevar_pop (TV_TO_SSA);
2958 /* Perform sparse conditional constant propagation, if requested. */
2961 timevar_push (TV_SSA_CCP);
2962 open_dump_file (DFI_ssa_ccp, decl);
2966 close_dump_file (DFI_ssa_ccp, print_rtl_with_bb, get_insns ());
2967 timevar_pop (TV_SSA_CCP);
2970 /* It would be useful to cleanup the CFG at this point, but block
2971 merging and possibly other transformations might leave a PHI
2972 node in the middle of a basic block, which is a strict no-no. */
2974 /* The SSA implementation uses basic block numbers in its phi
2975 nodes. Thus, changing the control-flow graph or the basic
2976 blocks, e.g., calling find_basic_blocks () or cleanup_cfg (),
2977 may cause problems. */
2981 /* Remove dead code. */
2983 timevar_push (TV_SSA_DCE);
2984 open_dump_file (DFI_ssa_dce, decl);
2986 insns = get_insns ();
2987 ssa_eliminate_dead_code ();
2989 close_dump_file (DFI_ssa_dce, print_rtl_with_bb, insns);
2990 timevar_pop (TV_SSA_DCE);
2993 /* Convert from SSA form. */
2995 timevar_push (TV_FROM_SSA);
2996 open_dump_file (DFI_ussa, decl);
2998 convert_from_ssa ();
2999 /* New registers have been created. Rescan their usage. */
3000 reg_scan (insns, max_reg_num (), 1);
3002 close_dump_file (DFI_ussa, print_rtl_with_bb, insns);
3003 timevar_pop (TV_FROM_SSA);
3010 /* Try to identify useless null pointer tests and delete them. */
3012 rest_of_handle_null_pointer (tree decl, rtx insns)
3014 open_dump_file (DFI_null, decl);
3016 dump_flow_info (rtl_dump_file);
3018 if (delete_null_pointer_checks (insns))
3019 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
3021 close_dump_file (DFI_null, print_rtl_with_bb, insns);
3024 /* Try combining insns through substitution. */
3026 rest_of_handle_combine (tree decl, rtx insns)
3028 int rebuild_jump_labels_after_combine = 0;
3030 timevar_push (TV_COMBINE);
3031 open_dump_file (DFI_combine, decl);
3033 rebuild_jump_labels_after_combine
3034 = combine_instructions (insns, max_reg_num ());
3036 /* Combining insns may have turned an indirect jump into a
3037 direct jump. Rebuild the JUMP_LABEL fields of jumping
3039 if (rebuild_jump_labels_after_combine)
3041 timevar_push (TV_JUMP);
3042 rebuild_jump_labels (insns);
3043 timevar_pop (TV_JUMP);
3045 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
3048 close_dump_file (DFI_combine, print_rtl_with_bb, insns);
3049 timevar_pop (TV_COMBINE);
3054 /* Perform life analysis. */
3056 rest_of_handle_life (tree decl, rtx insns)
3058 open_dump_file (DFI_life, decl);
3061 #ifdef ENABLE_CHECKING
3062 verify_flow_info ();
3064 life_analysis (insns, rtl_dump_file, PROP_FINAL);
3066 cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0) | CLEANUP_UPDATE_LIFE
3067 | (flag_thread_jumps ? CLEANUP_THREADING : 0));
3068 timevar_pop (TV_FLOW);
3070 if (warn_uninitialized)
3072 uninitialized_vars_warning (DECL_INITIAL (decl));
3074 setjmp_args_warning ();
3079 if (!flag_new_regalloc && initialize_uninitialized_subregs ())
3081 /* Insns were inserted, and possibly pseudos created, so
3082 things might look a bit different. */
3083 insns = get_insns ();
3084 allocate_reg_life_data ();
3085 update_life_info (NULL, UPDATE_LIFE_GLOBAL_RM_NOTES,
3086 PROP_LOG_LINKS | PROP_REG_INFO | PROP_DEATH_NOTES);
3092 close_dump_file (DFI_life, print_rtl_with_bb, insns);
3097 /* Perform common subexpression elimination. Nonzero value from
3098 `cse_main' means that jumps were simplified and some code may now
3099 be unreachable, so do jump optimization again. */
3101 rest_of_handle_cse (tree decl, rtx insns)
3105 open_dump_file (DFI_cse, decl);
3107 dump_flow_info (rtl_dump_file);
3108 timevar_push (TV_CSE);
3110 reg_scan (insns, max_reg_num (), 1);
3112 tem = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
3114 rebuild_jump_labels (insns);
3115 purge_all_dead_edges (0);
3117 delete_trivially_dead_insns (insns, max_reg_num ());
3119 /* If we are not running more CSE passes, then we are no longer
3120 expecting CSE to be run. But always rerun it in a cheap mode. */
3121 cse_not_expected = !flag_rerun_cse_after_loop && !flag_gcse;
3123 if (tem || optimize > 1)
3124 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
3125 /* Try to identify useless null pointer tests and delete them. */
3126 if (flag_delete_null_pointer_checks)
3128 timevar_push (TV_JUMP);
3130 if (delete_null_pointer_checks (insns))
3131 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
3132 timevar_pop (TV_JUMP);
3135 /* The second pass of jump optimization is likely to have
3136 removed a bunch more instructions. */
3137 renumber_insns (rtl_dump_file);
3139 timevar_pop (TV_CSE);
3140 close_dump_file (DFI_cse, print_rtl_with_bb, insns);
3143 /* Run second CSE pass after loop optimizations. */
3145 rest_of_handle_cse2 (tree decl, rtx insns)
3149 timevar_push (TV_CSE2);
3150 open_dump_file (DFI_cse2, decl);
3152 dump_flow_info (rtl_dump_file);
3153 /* CFG is no longer maintained up-to-date. */
3154 tem = cse_main (insns, max_reg_num (), 1, rtl_dump_file);
3155 purge_all_dead_edges (0);
3156 delete_trivially_dead_insns (insns, max_reg_num ());
3160 timevar_push (TV_JUMP);
3161 rebuild_jump_labels (insns);
3162 cleanup_cfg (CLEANUP_EXPENSIVE);
3163 timevar_pop (TV_JUMP);
3165 reg_scan (insns, max_reg_num (), 0);
3166 close_dump_file (DFI_cse2, print_rtl_with_bb, insns);
3168 timevar_pop (TV_CSE2);
3171 /* Perform global cse. */
3173 rest_of_handle_gcse (tree decl, rtx insns)
3175 int save_csb, save_cfj;
3178 timevar_push (TV_GCSE);
3179 open_dump_file (DFI_gcse, decl);
3181 tem = gcse_main (insns, rtl_dump_file);
3182 rebuild_jump_labels (insns);
3183 delete_trivially_dead_insns (insns, max_reg_num ());
3185 save_csb = flag_cse_skip_blocks;
3186 save_cfj = flag_cse_follow_jumps;
3187 flag_cse_skip_blocks = flag_cse_follow_jumps = 0;
3189 /* Instantiate any remaining CONSTANT_P_RTX nodes. */
3190 if (current_function_calls_constant_p)
3191 purge_builtin_constant_p ();
3193 /* If -fexpensive-optimizations, re-run CSE to clean up things done
3195 if (flag_expensive_optimizations)
3197 timevar_push (TV_CSE);
3198 reg_scan (insns, max_reg_num (), 1);
3199 tem2 = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
3200 purge_all_dead_edges (0);
3201 delete_trivially_dead_insns (insns, max_reg_num ());
3202 timevar_pop (TV_CSE);
3203 cse_not_expected = !flag_rerun_cse_after_loop;
3206 /* If gcse or cse altered any jumps, rerun jump optimizations to clean
3207 things up. Then possibly re-run CSE again. */
3211 timevar_push (TV_JUMP);
3212 rebuild_jump_labels (insns);
3213 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
3214 timevar_pop (TV_JUMP);
3216 if (flag_expensive_optimizations)
3218 timevar_push (TV_CSE);
3219 reg_scan (insns, max_reg_num (), 1);
3220 tem2 = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
3221 purge_all_dead_edges (0);
3222 delete_trivially_dead_insns (insns, max_reg_num ());
3223 timevar_pop (TV_CSE);
3227 close_dump_file (DFI_gcse, print_rtl_with_bb, insns);
3228 timevar_pop (TV_GCSE);
3231 flag_cse_skip_blocks = save_csb;
3232 flag_cse_follow_jumps = save_cfj;
3233 #ifdef ENABLE_CHECKING
3234 verify_flow_info ();
3238 /* Move constant computations out of loops. */
3240 rest_of_handle_loop_optimize (tree decl, rtx insns)
3242 int do_unroll, do_prefetch;
3244 timevar_push (TV_LOOP);
3245 delete_dead_jumptables ();
3246 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
3247 open_dump_file (DFI_loop, decl);
3249 /* CFG is no longer maintained up-to-date. */
3250 free_bb_for_insn ();
3252 if (flag_unroll_loops)
3253 do_unroll = 0; /* Having two unrollers is useless. */
3255 do_unroll = flag_old_unroll_loops ? LOOP_UNROLL : LOOP_AUTO_UNROLL;
3256 do_prefetch = flag_prefetch_loop_arrays ? LOOP_PREFETCH : 0;
3258 if (flag_rerun_loop_opt)
3260 cleanup_barriers ();
3262 /* We only want to perform unrolling once. */
3263 loop_optimize (insns, rtl_dump_file, do_unroll);
3266 /* The first call to loop_optimize makes some instructions
3267 trivially dead. We delete those instructions now in the
3268 hope that doing so will make the heuristics in loop work
3269 better and possibly speed up compilation. */
3270 delete_trivially_dead_insns (insns, max_reg_num ());
3272 /* The regscan pass is currently necessary as the alias
3273 analysis code depends on this information. */
3274 reg_scan (insns, max_reg_num (), 1);
3276 cleanup_barriers ();
3277 loop_optimize (insns, rtl_dump_file, do_unroll | LOOP_BCT | do_prefetch);
3279 /* Loop can create trivially dead instructions. */
3280 delete_trivially_dead_insns (insns, max_reg_num ());
3281 close_dump_file (DFI_loop, print_rtl, insns);
3282 timevar_pop (TV_LOOP);
3283 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3288 /* Perform loop optimalizations. It might be better to do them a bit
3289 sooner, but we want the profile feedback to work more
3292 rest_of_handle_loop2 (tree decl, rtx insns)
3294 struct loops *loops;
3295 timevar_push (TV_LOOP);
3296 open_dump_file (DFI_loop2, decl);
3298 dump_flow_info (rtl_dump_file);
3300 loops = loop_optimizer_init (rtl_dump_file);
3304 /* The optimalizations: */
3305 if (flag_unswitch_loops)
3306 unswitch_loops (loops);
3308 if (flag_peel_loops || flag_unroll_loops)
3309 unroll_and_peel_loops (loops,
3310 (flag_peel_loops ? UAP_PEEL : 0) |
3311 (flag_unroll_loops ? UAP_UNROLL : 0) |
3312 (flag_unroll_all_loops ? UAP_UNROLL_ALL : 0));
3314 loop_optimizer_finalize (loops, rtl_dump_file);
3317 cleanup_cfg (CLEANUP_EXPENSIVE);
3318 delete_trivially_dead_insns (insns, max_reg_num ());
3319 reg_scan (insns, max_reg_num (), 0);
3321 dump_flow_info (rtl_dump_file);
3322 close_dump_file (DFI_loop2, print_rtl_with_bb, get_insns ());
3323 timevar_pop (TV_LOOP);
3327 /* This is called from finish_function (within langhooks.parse_file)
3328 after each top-level definition is parsed.
3329 It is supposed to compile that function or variable
3330 and output the assembler code for it.
3331 After we return, the tree storage is freed. */
3334 rest_of_compilation (tree decl)
3337 int rebuild_label_notes_after_reload;
3339 timevar_push (TV_REST_OF_COMPILATION);
3341 /* Register rtl specific functions for cfg. */
3342 rtl_register_cfg_hooks ();
3344 /* Now that we're out of the frontend, we shouldn't have any more
3345 CONCATs anywhere. */
3346 generating_concat_p = 0;
3348 /* When processing delayed functions, prepare_function_start() won't
3349 have been run to re-initialize it. */
3350 cse_not_expected = ! optimize;
3352 /* First, make sure that NOTE_BLOCK is set correctly for each
3353 NOTE_INSN_BLOCK_BEG/NOTE_INSN_BLOCK_END note. */
3354 if (!cfun->x_whole_function_mode_p)
3357 /* In function-at-a-time mode, we do not attempt to keep the BLOCK
3358 tree in sensible shape. So, we just recalculate it here. */
3359 if (cfun->x_whole_function_mode_p)
3364 if (rest_of_handle_inlining (decl))
3365 goto exit_rest_of_compilation;
3367 /* If we're emitting a nested function, make sure its parent gets
3368 emitted as well. Doing otherwise confuses debug info. */
3371 for (parent = DECL_CONTEXT (current_function_decl);
3372 parent != NULL_TREE;
3373 parent = get_containing_scope (parent))
3374 if (TREE_CODE (parent) == FUNCTION_DECL)
3375 TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (parent)) = 1;
3378 /* We are now committed to emitting code for this function. Do any
3379 preparation, such as emitting abstract debug info for the inline
3380 before it gets mangled by optimization. */
3381 if (DECL_INLINE (decl))
3382 (*debug_hooks->outlining_inline_function) (decl);
3384 /* Remove any notes we don't need. That will make iterating
3385 over the instruction sequence faster, and allow the garbage
3386 collector to reclaim the memory used by the notes. */
3387 remove_unnecessary_notes ();
3392 /* Initialize some variables used by the optimizers. */
3393 init_function_for_compilation ();
3395 if (! DECL_DEFER_OUTPUT (decl))
3396 TREE_ASM_WRITTEN (decl) = 1;
3398 /* Now that integrate will no longer see our rtl, we need not
3399 distinguish between the return value of this function and the
3400 return value of called functions. Also, we can remove all SETs
3401 of subregs of hard registers; they are only here because of
3402 integrate. Also, we can now initialize pseudos intended to
3403 carry magic hard reg data throughout the function. */
3404 rtx_equal_function_value_matters = 0;
3405 purge_hard_subreg_sets (get_insns ());
3407 /* Early return if there were errors. We can run afoul of our
3408 consistency checks, and there's not really much point in fixing them.
3409 Don't return yet if -Wreturn-type; we need to do cleanup_cfg. */
3410 if (((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
3411 || errorcount || sorrycount)
3412 goto exit_rest_of_compilation;
3414 timevar_push (TV_JUMP);
3415 open_dump_file (DFI_sibling, decl);
3416 insns = get_insns ();
3417 rebuild_jump_labels (insns);
3418 find_exception_handler_labels ();
3419 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3421 delete_unreachable_blocks ();
3423 /* We have to issue these warnings now already, because CFG cleanups
3424 further down may destroy the required information. */
3425 check_function_return_warnings ();
3427 /* Turn NOTE_INSN_PREDICTIONs into branch predictions. */
3428 if (flag_guess_branch_prob)
3430 timevar_push (TV_BRANCH_PROB);
3431 note_prediction_to_br_prob ();
3432 timevar_pop (TV_BRANCH_PROB);
3435 if (flag_optimize_sibling_calls)
3436 rest_of_handle_sibling_calls (insns);
3438 timevar_pop (TV_JUMP);
3440 insn_locators_initialize ();
3441 /* Complete generation of exception handling code. */
3444 timevar_push (TV_JUMP);
3445 open_dump_file (DFI_eh, decl);
3447 finish_eh_generation ();
3449 close_dump_file (DFI_eh, print_rtl, get_insns ());
3450 timevar_pop (TV_JUMP);
3453 /* Delay emitting hard_reg_initial_value sets until after EH landing pad
3454 generation, which might create new sets. */
3455 emit_initial_value_sets ();
3458 /* If we are doing position-independent code generation, now
3459 is the time to output special prologues and epilogues.
3460 We do not want to do this earlier, because it just clutters
3461 up inline functions with meaningless insns. */
3466 insns = get_insns ();
3468 /* Copy any shared structure that should not be shared. */
3469 unshare_all_rtl (current_function_decl, insns);
3471 #ifdef SETJMP_VIA_SAVE_AREA
3472 /* This must be performed before virtual register instantiation.
3473 Please be aware the everything in the compiler that can look
3474 at the RTL up to this point must understand that REG_SAVE_AREA
3475 is just like a use of the REG contained inside. */
3476 if (current_function_calls_alloca)
3477 optimize_save_area_alloca (insns);
3480 /* Instantiate all virtual registers. */
3481 instantiate_virtual_regs (current_function_decl, insns);
3483 open_dump_file (DFI_jump, decl);
3485 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
3486 are initialized and to compute whether control can drop off the end
3489 timevar_push (TV_JUMP);
3490 /* Turn NOTE_INSN_EXPECTED_VALUE into REG_BR_PROB. Do this
3491 before jump optimization switches branch directions. */
3492 if (flag_guess_branch_prob)
3493 expected_value_to_br_prob ();
3495 reg_scan (insns, max_reg_num (), 0);
3496 rebuild_jump_labels (insns);
3497 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3498 delete_trivially_dead_insns (insns, max_reg_num ());
3500 dump_flow_info (rtl_dump_file);
3501 cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0) | CLEANUP_PRE_LOOP
3502 | (flag_thread_jumps ? CLEANUP_THREADING : 0));
3506 free_bb_for_insn ();
3507 copy_loop_headers (insns);
3508 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3510 purge_line_number_notes (insns);
3512 timevar_pop (TV_JUMP);
3513 close_dump_file (DFI_jump, print_rtl, insns);
3515 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
3516 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
3517 goto exit_rest_of_compilation;
3519 /* Long term, this should probably move before the jump optimizer too,
3520 but I didn't want to disturb the rtl_dump_and_exit and related
3521 stuff at this time. */
3522 if (optimize > 0 && flag_ssa)
3523 insns = rest_of_handle_ssa (decl, insns);
3525 timevar_push (TV_JUMP);
3528 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
3530 if (flag_delete_null_pointer_checks)
3531 rest_of_handle_null_pointer (decl, insns);
3533 /* Jump optimization, and the removal of NULL pointer checks, may
3534 have reduced the number of instructions substantially. CSE, and
3535 future passes, allocate arrays whose dimensions involve the
3536 maximum instruction UID, so if we can reduce the maximum UID
3537 we'll save big on memory. */
3538 renumber_insns (rtl_dump_file);
3539 timevar_pop (TV_JUMP);
3541 close_dump_file (DFI_jump, print_rtl_with_bb, insns);
3546 rest_of_handle_cse (decl, insns);
3548 rest_of_handle_addresof (decl, insns);
3555 rest_of_handle_gcse (decl, insns);
3557 if (flag_loop_optimize)
3558 rest_of_handle_loop_optimize (decl, insns);
3561 rest_of_handle_jump_bypass (decl, insns);
3564 timevar_push (TV_FLOW);
3566 rest_of_handle_cfg (decl, insns);
3569 || profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
3570 rest_of_handle_branch_prob (decl, insns);
3573 rest_of_handle_if_conversion (decl, insns);
3576 rest_of_handle_tracer (decl, insns);
3579 && (flag_unswitch_loops
3581 || flag_unroll_loops))
3582 rest_of_handle_loop2 (decl, insns);
3584 if (flag_rerun_cse_after_loop)
3585 rest_of_handle_cse2 (decl, insns);
3587 cse_not_expected = 1;
3589 rest_of_handle_life (decl, insns);
3592 rest_of_handle_combine (decl, insns);
3594 if (flag_if_conversion)
3595 rest_of_handle_if_after_combine (decl, insns);
3597 if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
3598 rest_of_handle_regmove (decl, insns);
3600 /* Do unconditional splitting before register allocation to allow machine
3601 description to add extra information not needed previously. */
3602 split_all_insns (1);
3604 #ifdef OPTIMIZE_MODE_SWITCHING
3605 timevar_push (TV_MODE_SWITCH);
3608 optimize_mode_switching (NULL);
3611 timevar_pop (TV_MODE_SWITCH);
3614 /* Any of the several passes since flow1 will have munged register
3615 lifetime data a bit. We need it to be up to date for scheduling
3616 (see handling of reg_known_equiv in init_alias_analysis). */
3617 recompute_reg_usage (insns, !optimize_size);
3619 #ifdef INSN_SCHEDULING
3620 rest_of_handle_sched (decl, insns);
3623 /* Determine if the current function is a leaf before running reload
3624 since this can impact optimizations done by the prologue and
3625 epilogue thus changing register elimination offsets. */
3626 current_function_is_leaf = leaf_function_p ();
3628 timevar_push (TV_LOCAL_ALLOC);
3629 open_dump_file (DFI_lreg, decl);
3631 if (flag_new_regalloc)
3633 if (rest_of_handle_new_regalloc (decl, insns,
3634 &rebuild_label_notes_after_reload))
3635 goto exit_rest_of_compilation;
3639 if (rest_of_handle_old_regalloc (decl, insns,
3640 &rebuild_label_notes_after_reload))
3641 goto exit_rest_of_compilation;
3646 open_dump_file (DFI_postreload, decl);
3648 /* Do a very simple CSE pass over just the hard registers. */
3651 timevar_push (TV_RELOAD_CSE_REGS);
3652 reload_cse_regs (insns);
3653 timevar_pop (TV_RELOAD_CSE_REGS);
3656 /* Register allocation and reloading may have turned an indirect jump into
3657 a direct jump. If so, we must rebuild the JUMP_LABEL fields of
3658 jumping instructions. */
3659 if (rebuild_label_notes_after_reload)
3661 timevar_push (TV_JUMP);
3663 rebuild_jump_labels (insns);
3664 purge_all_dead_edges (0);
3666 timevar_pop (TV_JUMP);
3669 close_dump_file (DFI_postreload, print_rtl_with_bb, insns);
3671 /* Re-create the death notes which were deleted during reload. */
3672 timevar_push (TV_FLOW2);
3673 open_dump_file (DFI_flow2, decl);
3675 #ifdef ENABLE_CHECKING
3676 verify_flow_info ();
3679 /* If optimizing, then go ahead and split insns now. */
3683 split_all_insns (0);
3685 if (flag_branch_target_load_optimize)
3687 open_dump_file (DFI_branch_target_load, decl);
3689 branch_target_load_optimize (insns, false);
3691 close_dump_file (DFI_branch_target_load, print_rtl_with_bb, insns);
3697 cleanup_cfg (CLEANUP_EXPENSIVE);
3699 /* On some machines, the prologue and epilogue code, or parts thereof,
3700 can be represented as RTL. Doing so lets us schedule insns between
3701 it and the rest of the code and also allows delayed branch
3702 scheduling to operate in the epilogue. */
3703 thread_prologue_and_epilogue_insns (insns);
3704 epilogue_completed = 1;
3708 life_analysis (insns, rtl_dump_file, PROP_FINAL);
3709 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE
3710 | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0));
3712 /* This is kind of a heuristic. We need to run combine_stack_adjustments
3713 even for machines with possibly nonzero RETURN_POPS_ARGS
3714 and ACCUMULATE_OUTGOING_ARGS. We expect that only ports having
3715 push instructions will have popping returns. */
3716 #ifndef PUSH_ROUNDING
3717 if (!ACCUMULATE_OUTGOING_ARGS)
3719 combine_stack_adjustments ();
3724 flow2_completed = 1;
3726 close_dump_file (DFI_flow2, print_rtl_with_bb, insns);
3727 timevar_pop (TV_FLOW2);
3729 #ifdef HAVE_peephole2
3730 if (optimize > 0 && flag_peephole2)
3732 timevar_push (TV_PEEPHOLE2);
3733 open_dump_file (DFI_peephole2, decl);
3735 peephole2_optimize (rtl_dump_file);
3737 close_dump_file (DFI_peephole2, print_rtl_with_bb, insns);
3738 timevar_pop (TV_PEEPHOLE2);
3744 if (flag_rename_registers || flag_cprop_registers)
3745 rest_of_handle_regrename (decl, insns);
3747 rest_of_handle_reorder_blocks (decl, insns);
3750 if (flag_if_conversion2)
3752 timevar_push (TV_IFCVT2);
3753 open_dump_file (DFI_ce3, decl);
3757 close_dump_file (DFI_ce3, print_rtl_with_bb, insns);
3758 timevar_pop (TV_IFCVT2);
3761 if (flag_branch_target_load_optimize2)
3763 /* Leave this a warning for now so that it is possible to experiment
3764 with running this pass twice. In 3.6, we should either make this
3765 an error, or use separate dump files. */
3766 if (flag_branch_target_load_optimize)
3767 warning ("branch target register load optimization is not intended "
3770 open_dump_file (DFI_branch_target_load, decl);
3772 branch_target_load_optimize (insns, true);
3774 close_dump_file (DFI_branch_target_load, print_rtl_with_bb, insns);
3779 #ifdef INSN_SCHEDULING
3780 if (optimize > 0 && flag_schedule_insns_after_reload)
3781 rest_of_handle_sched2 (decl, insns);
3784 #ifdef LEAF_REGISTERS
3785 current_function_uses_only_leaf_regs
3786 = optimize > 0 && only_leaf_regs_used () && leaf_function_p ();
3790 rest_of_handle_stack_regs (decl, insns);
3793 compute_alignments ();
3795 /* CFG is no longer maintained up-to-date. */
3796 free_bb_for_insn ();
3798 if (targetm.machine_dependent_reorg != 0)
3799 rest_of_handle_machine_reorg (decl, insns);
3801 purge_line_number_notes (insns);
3802 cleanup_barriers ();
3805 if (optimize > 0 && flag_delayed_branch)
3806 rest_of_handle_delay_slots (decl, insns);
3809 #if defined (HAVE_ATTR_length) && !defined (STACK_REGS)
3810 timevar_push (TV_SHORTEN_BRANCH);
3811 split_all_insns_noflow ();
3812 timevar_pop (TV_SHORTEN_BRANCH);
3815 convert_to_eh_region_ranges ();
3817 /* Shorten branches. */
3818 timevar_push (TV_SHORTEN_BRANCH);
3819 shorten_branches (get_insns ());
3820 timevar_pop (TV_SHORTEN_BRANCH);
3822 set_nothrow_function_flags ();
3823 if (current_function_nothrow)
3824 /* Now we know that this can't throw; set the flag for the benefit
3825 of other functions later in this translation unit. */
3826 TREE_NOTHROW (current_function_decl) = 1;
3828 rest_of_handle_final (decl, insns);
3830 /* Write DBX symbols if requested. */
3832 /* Note that for those inline functions where we don't initially
3833 know for certain that we will be generating an out-of-line copy,
3834 the first invocation of this routine (rest_of_compilation) will
3835 skip over this code by doing a `goto exit_rest_of_compilation;'.
3836 Later on, wrapup_global_declarations will (indirectly) call
3837 rest_of_compilation again for those inline functions that need
3838 to have out-of-line copies generated. During that call, we
3839 *will* be routed past here. */
3841 timevar_push (TV_SYMOUT);
3842 (*debug_hooks->function_decl) (decl);
3843 timevar_pop (TV_SYMOUT);
3845 exit_rest_of_compilation:
3847 coverage_end_function ();
3849 /* In case the function was not output,
3850 don't leave any temporary anonymous types
3851 queued up for sdb output. */
3852 #ifdef SDB_DEBUGGING_INFO
3853 if (write_symbols == SDB_DEBUG)
3854 sdbout_types (NULL_TREE);
3857 reload_completed = 0;
3858 epilogue_completed = 0;
3859 flow2_completed = 0;
3862 timevar_push (TV_FINAL);
3864 /* Clear out the insn_length contents now that they are no
3866 init_insn_lengths ();
3868 /* Show no temporary slots allocated. */
3871 free_basic_block_vars (0);
3872 free_bb_for_insn ();
3874 timevar_pop (TV_FINAL);
3876 if ((*targetm.binds_local_p) (current_function_decl))
3878 int pref = cfun->preferred_stack_boundary;
3879 if (cfun->recursive_call_emit
3880 && cfun->stack_alignment_needed > cfun->preferred_stack_boundary)
3881 pref = cfun->stack_alignment_needed;
3882 cgraph_rtl_info (current_function_decl)->preferred_incoming_stack_boundary
3886 /* Make sure volatile mem refs aren't considered valid operands for
3887 arithmetic insns. We must call this here if this is a nested inline
3888 function, since the above code leaves us in the init_recog state
3889 (from final.c), and the function context push/pop code does not
3890 save/restore volatile_ok.
3892 ??? Maybe it isn't necessary for expand_start_function to call this
3893 anymore if we do it here? */
3895 init_recog_no_volatile ();
3897 /* We're done with this function. Free up memory if we can. */
3898 free_after_parsing (cfun);
3899 if (! DECL_DEFER_OUTPUT (decl))
3901 free_after_compilation (cfun);
3903 /* Clear integrate.c's pointer to the cfun structure we just
3905 DECL_SAVED_INSNS (decl) = 0;
3911 timevar_pop (TV_REST_OF_COMPILATION);
3914 /* Display help for generic options. */
3922 printf (_(" -ffixed-<register> Mark <register> as being unavailable to the compiler\n"));
3923 printf (_(" -fcall-used-<register> Mark <register> as being corrupted by function calls\n"));
3924 printf (_(" -fcall-saved-<register> Mark <register> as being preserved across functions\n"));
3925 printf (_(" -finline-limit=<number> Limits the size of inlined functions to <number>\n"));
3926 printf (_(" -fmessage-length=<number> Limits diagnostics messages lengths to <number> characters per line. 0 suppresses line-wrapping\n"));
3927 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"));
3928 printf (_(" -ftls-model=[global-dynamic | local-dynamic | initial-exec | local-exec] Indicates the default thread-local storage code generation model\n"));
3929 printf (_(" -fstack-limit-register=<register> Trap if the stack goes past <register>\n"));
3930 printf (_(" -fstack-limit-symbol=<name> Trap if the stack goes past symbol <name>\n"));
3931 printf (_(" -frandom-seed=<string> Make compile reproducible using <string>\n"));
3934 for (i = ARRAY_SIZE (f_options); i--;)
3936 const char *description = f_options[i].description;
3938 if (description != NULL && *description != 0)
3939 printf (" -f%-21s %s\n",
3940 f_options[i].string, _(description));
3943 printf (_(" -O[number] Set optimization level to [number]\n"));
3944 printf (_(" -Os Optimize for space rather than speed\n"));
3945 for (i = LAST_PARAM; i--;)
3947 const char *description = compiler_params[i].help;
3948 const int length = 21 - strlen (compiler_params[i].option);
3950 if (description != NULL && *description != 0)
3951 printf (" --param %s=<value>%.*s%s\n",
3952 compiler_params[i].option,
3953 length > 0 ? length : 1, " ",
3956 printf (_(" -pedantic Issue warnings needed by strict compliance to ISO C\n"));
3957 printf (_(" -pedantic-errors Like -pedantic except that errors are produced\n"));
3958 printf (_(" -w Suppress warnings\n"));
3960 for (i = ARRAY_SIZE (W_options); i--;)
3962 const char *description = W_options[i].description;
3964 if (description != NULL && *description != 0)
3965 printf (" -W%-21s %s\n",
3966 W_options[i].string, _(description));
3969 printf (_(" -Wextra Print extra (possibly unwanted) warnings\n"));
3970 printf (_(" -Wunused Enable unused warnings\n"));
3971 printf (_(" -Wlarger-than-<number> Warn if an object is larger than <number> bytes\n"));
3972 printf (_(" -p Enable function profiling\n"));
3973 printf (_(" -o <file> Place output into <file> \n"));
3975 -G <number> Put global and static data smaller than <number>\n\
3976 bytes into a special section (on some targets)\n"));
3978 for (i = ARRAY_SIZE (debug_args); i--;)
3980 if (debug_args[i].description != NULL)
3981 printf (" -g%-21s %s\n",
3982 debug_args[i].arg, _(debug_args[i].description));
3985 printf (_(" -aux-info <file> Emit declaration info into <file>\n"));
3986 printf (_(" -quiet Do not display functions compiled or elapsed time\n"));
3987 printf (_(" -version Display the compiler's version\n"));
3988 printf (_(" -d[letters] Enable dumps from specific passes of the compiler\n"));
3989 printf (_(" -dumpbase <file> Base name to be used for dumps from specific passes\n"));
3990 #if defined INSN_SCHEDULING
3991 printf (_(" -fsched-verbose=<number> Set the verbosity level of the scheduler\n"));
3993 printf (_(" --help Display this information\n"));
3998 /* Display descriptions of language specific options.
3999 If there is no description, note that there is an undocumented option.
4000 If the description is empty, do not display anything. (This allows
4001 options to be deliberately undocumented, for whatever reason).
4002 If the option string is missing, then this is a marker, indicating
4003 that the description string is in fact the name of a language, whose
4004 language specific options are to follow. */
4006 if (ARRAY_SIZE (documented_lang_options) > 1)
4008 printf (_("\nLanguage specific options:\n"));
4010 for (i = 0; i < ARRAY_SIZE (documented_lang_options); i++)
4012 const char *description = documented_lang_options[i].description;
4013 const char *option = documented_lang_options[i].option;
4015 if (description == NULL)
4020 printf (_(" %-23.23s [undocumented]\n"), option);
4022 else if (*description == 0)
4024 else if (option == NULL)
4028 (_("\nThere are undocumented %s specific options as well.\n"),
4032 printf (_("\n Options for %s:\n"), description);
4037 printf (" %-23.23s %s\n", option, _(description));
4042 printf (_("\nThere are undocumented %s specific options as well.\n"),
4045 display_target_options ();
4048 /* Display help for target options. */
4050 display_target_options (void)
4053 static bool displayed = false;
4055 /* Avoid double printing for --help --target-help. */
4061 if (ARRAY_SIZE (target_switches) > 1
4062 #ifdef TARGET_OPTIONS
4063 || ARRAY_SIZE (target_options) > 1
4071 printf (_("\nTarget specific options:\n"));
4073 for (i = ARRAY_SIZE (target_switches); i--;)
4075 const char *option = target_switches[i].name;
4076 const char *description = target_switches[i].description;
4078 if (option == NULL || *option == 0)
4080 else if (description == NULL)
4085 printf (_(" -m%-23.23s [undocumented]\n"), option);
4087 else if (*description != 0)
4088 doc += printf (" -m%-23.23s %s\n", option, _(description));
4091 #ifdef TARGET_OPTIONS
4092 for (i = ARRAY_SIZE (target_options); i--;)
4094 const char *option = target_options[i].prefix;
4095 const char *description = target_options[i].description;
4097 if (option == NULL || *option == 0)
4099 else if (description == NULL)
4104 printf (_(" -m%-23.23s [undocumented]\n"), option);
4106 else if (*description != 0)
4107 doc += printf (" -m%-23.23s %s\n", option, _(description));
4113 printf (_("\nThere are undocumented target specific options as well.\n"));
4115 printf (_(" They exist, but they are not documented.\n"));
4120 /* Parse a -d... command line switch. */
4123 decode_d_option (const char *arg)
4131 for (i = 0; i < (int) DFI_MAX; ++i)
4132 dump_file[i].enabled = 1;
4138 flag_print_asm_name = 1;
4141 flag_dump_rtl_in_asm = 1;
4142 flag_print_asm_name = 1;
4145 graph_dump_format = vcg;
4148 rtl_dump_and_exit = 1;
4153 case 'D': /* These are handled by the preprocessor. */
4157 setup_core_dumping();
4162 for (i = 0; i < (int) DFI_MAX; ++i)
4163 if (c == dump_file[i].debug_switch)
4165 dump_file[i].enabled = 1;
4170 warning ("unrecognized gcc debugging option: %c", c);
4175 /* Indexed by enum debug_info_type. */
4176 const char *const debug_type_names[] =
4178 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff", "vms"
4181 /* Parse a -g... command line switch. ARG is the value after the -g.
4182 It is safe to access 'ARG - 2' to generate the full switch name.
4183 Return the number of strings consumed. */
4186 decode_g_option (const char *arg)
4188 static unsigned level = 0;
4189 /* A lot of code assumes write_symbols == NO_DEBUG if the
4190 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
4191 of what debugging type has been selected). This records the
4192 selected type. It is an error to specify more than one
4194 static enum debug_info_type selected_debug_type = NO_DEBUG;
4195 /* Nonzero if debugging format has been explicitly set.
4196 -g and -ggdb don't explicitly set the debugging format so
4197 -gdwarf -g3 is equivalent to -gdwarf3. */
4198 static int type_explicitly_set_p = 0;
4200 /* The maximum admissible debug level value. */
4201 static const unsigned max_debug_level = 3;
4203 /* Look up ARG in the table. */
4204 for (da = debug_args; da->arg; da++)
4206 const int da_len = strlen (da->arg);
4208 if (da_len == 0 || ! strncmp (arg, da->arg, da_len))
4210 enum debug_info_type type = da->debug_type;
4211 const char *p = arg + da_len;
4213 if (*p && ! ISDIGIT (*p))
4216 /* A debug flag without a level defaults to level 2.
4217 Note we do not want to call read_integral_parameter
4218 for that case since it will call atoi which
4221 ??? We may want to generalize the interface to
4222 read_integral_parameter to better handle this case
4223 if this case shows up often. */
4225 level = read_integral_parameter (p, 0, max_debug_level + 1);
4227 level = (level == 0) ? 2 : level;
4229 if (da_len > 1 && *p && !strncmp (arg, "dwarf", da_len))
4231 error ("use -gdwarf -g%d for DWARF v1, level %d",
4234 error ("use -gdwarf-2 for DWARF v2");
4237 if (level > max_debug_level)
4240 ignoring option `%s' due to invalid debug level specification",
4242 level = debug_info_level;
4245 if (type == NO_DEBUG)
4247 type = PREFERRED_DEBUGGING_TYPE;
4249 if (da_len > 1 && strncmp (arg, "gdb", da_len) == 0)
4251 #ifdef DWARF2_DEBUGGING_INFO
4252 type = DWARF2_DEBUG;
4254 #ifdef DBX_DEBUGGING_INFO
4261 if (type == NO_DEBUG)
4262 warning ("`%s': unknown or unsupported -g option", arg - 2);
4264 /* Does it conflict with an already selected type? */
4265 if (type_explicitly_set_p
4266 /* -g/-ggdb don't conflict with anything. */
4267 && da->debug_type != NO_DEBUG
4268 && type != selected_debug_type)
4269 warning ("`%s' ignored, conflicts with `-g%s'",
4270 arg - 2, debug_type_names[(int) selected_debug_type]);
4273 /* If the format has already been set, -g/-ggdb
4274 only change the debug level. */
4275 if (type_explicitly_set_p && da->debug_type == NO_DEBUG)
4276 /* Don't change debugging type. */
4280 selected_debug_type = type;
4281 type_explicitly_set_p = da->debug_type != NO_DEBUG;
4284 write_symbols = (level == 0
4286 : selected_debug_type);
4287 use_gnu_debug_info_extensions = da->use_extensions_p;
4288 debug_info_level = (enum debug_info_level) level;
4296 warning ("`-g%s': unknown or unsupported -g option", arg);
4299 /* Decode -m switches. */
4300 /* Decode the switch -mNAME. */
4303 set_target_switch (const char *name)
4306 int valid_target_option = 0;
4308 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
4309 if (!strcmp (target_switches[j].name, name))
4311 if (target_switches[j].value < 0)
4312 target_flags &= ~-target_switches[j].value;
4314 target_flags |= target_switches[j].value;
4317 if (target_switches[j].value < 0)
4318 target_flags_explicit |= -target_switches[j].value;
4320 target_flags_explicit |= target_switches[j].value;
4322 valid_target_option = 1;
4325 #ifdef TARGET_OPTIONS
4326 if (!valid_target_option)
4327 for (j = 0; j < ARRAY_SIZE (target_options); j++)
4329 int len = strlen (target_options[j].prefix);
4330 if (target_options[j].value)
4332 if (!strcmp (target_options[j].prefix, name))
4334 *target_options[j].variable = target_options[j].value;
4335 valid_target_option = 1;
4340 if (!strncmp (target_options[j].prefix, name, len))
4342 *target_options[j].variable = name + len;
4343 valid_target_option = 1;
4349 if (!valid_target_option)
4350 error ("invalid option `%s'", name);
4353 /* Print version information to FILE.
4354 Each line begins with INDENT (for the case where FILE is the
4355 assembler output file). */
4358 print_version (FILE *file, const char *indent)
4361 #define __VERSION__ "[?]"
4365 "%s%s%s version %s (%s)\n%s\tcompiled by GNU C version %s.\n"
4367 "%s%s%s version %s (%s) compiled by CC.\n"
4369 , indent, *indent != 0 ? " " : "",
4370 lang_hooks.name, version_string, TARGET_NAME,
4371 indent, __VERSION__);
4372 fnotice (file, "%s%sGGC heuristics: --param ggc-min-expand=%d --param ggc-min-heapsize=%d\n",
4373 indent, *indent != 0 ? " " : "",
4374 PARAM_VALUE (GGC_MIN_EXPAND), PARAM_VALUE (GGC_MIN_HEAPSIZE));
4377 /* Print an option value and return the adjusted position in the line.
4378 ??? We don't handle error returns from fprintf (disk full); presumably
4379 other code will catch a disk full though. */
4382 print_single_switch (FILE *file, int pos, int max,
4383 const char *indent, const char *sep, const char *term,
4384 const char *type, const char *name)
4386 /* The ultrix fprintf returns 0 on success, so compute the result we want
4387 here since we need it for the following test. */
4388 int len = strlen (sep) + strlen (type) + strlen (name);
4393 fprintf (file, "%s", term);
4398 fprintf (file, "%s", indent);
4399 pos = strlen (indent);
4401 fprintf (file, "%s%s%s", sep, type, name);
4406 /* Print active target switches to FILE.
4407 POS is the current cursor position and MAX is the size of a "line".
4408 Each line begins with INDENT and ends with TERM.
4409 Each switch is separated from the next by SEP. */
4412 print_switch_values (FILE *file, int pos, int max,
4413 const char *indent, const char *sep, const char *term)
4418 /* Fill in the -frandom-seed option, if the user didn't pass it, so
4419 that it can be printed below. This helps reproducibility. Of
4420 course, the string may never be used, but we can't tell that at
4421 this point in the compile. */
4422 default_flag_random_seed ();
4424 /* Print the options as passed. */
4426 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
4427 _("options passed: "), "");
4429 for (p = &save_argv[1]; *p != NULL; p++)
4433 if (strcmp (*p, "-o") == 0)
4439 if (strcmp (*p, "-quiet") == 0)
4441 if (strcmp (*p, "-version") == 0)
4446 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
4449 fprintf (file, "%s", term);
4451 /* Print the -f and -m options that have been enabled.
4452 We don't handle language specific options but printing argv
4455 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
4456 _("options enabled: "), "");
4458 for (j = 0; j < ARRAY_SIZE (f_options); j++)
4459 if (*f_options[j].variable == f_options[j].on_value)
4460 pos = print_single_switch (file, pos, max, indent, sep, term,
4461 "-f", f_options[j].string);
4463 /* Print target specific options. */
4465 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
4466 if (target_switches[j].name[0] != '\0'
4467 && target_switches[j].value > 0
4468 && ((target_switches[j].value & target_flags)
4469 == target_switches[j].value))
4471 pos = print_single_switch (file, pos, max, indent, sep, term,
4472 "-m", target_switches[j].name);
4475 #ifdef TARGET_OPTIONS
4476 for (j = 0; j < ARRAY_SIZE (target_options); j++)
4477 if (*target_options[j].variable != NULL)
4480 sprintf (prefix, "-m%s", target_options[j].prefix);
4481 pos = print_single_switch (file, pos, max, indent, sep, term,
4482 prefix, *target_options[j].variable);
4486 fprintf (file, "%s", term);
4489 /* Open assembly code output file. Do this even if -fsyntax-only is
4490 on, because then the driver will have provided the name of a
4491 temporary file or bit bucket for us. NAME is the file specified on
4492 the command line, possibly NULL. */
4494 init_asm_output (const char *name)
4496 if (name == NULL && asm_file_name == 0)
4497 asm_out_file = stdout;
4500 if (asm_file_name == 0)
4502 int len = strlen (dump_base_name);
4503 char *dumpname = (char *) xmalloc (len + 6);
4504 memcpy (dumpname, dump_base_name, len + 1);
4505 strip_off_ending (dumpname, len);
4506 strcat (dumpname, ".s");
4507 asm_file_name = dumpname;
4509 if (!strcmp (asm_file_name, "-"))
4510 asm_out_file = stdout;
4512 asm_out_file = fopen (asm_file_name, "w+");
4513 if (asm_out_file == 0)
4514 fatal_error ("can't open %s for writing: %m", asm_file_name);
4517 #ifdef IO_BUFFER_SIZE
4518 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
4519 _IOFBF, IO_BUFFER_SIZE);
4522 if (!flag_syntax_only)
4524 targetm.asm_out.file_start ();
4526 #ifdef ASM_COMMENT_START
4527 if (flag_verbose_asm)
4529 /* Print the list of options in effect. */
4530 print_version (asm_out_file, ASM_COMMENT_START);
4531 print_switch_values (asm_out_file, 0, MAX_LINE,
4532 ASM_COMMENT_START, " ", "\n");
4533 /* Add a blank line here so it appears in assembler output but not
4535 fprintf (asm_out_file, "\n");
4541 /* Initialization of the front end environment, before command line
4542 options are parsed. Signal handlers, internationalization etc.
4543 ARGV0 is main's argv[0]. */
4545 general_init (char *argv0)
4549 p = argv0 + strlen (argv0);
4550 while (p != argv0 && !IS_DIR_SEPARATOR (p[-1]))
4554 xmalloc_set_program_name (progname);
4558 gcc_init_libintl ();
4560 /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages. */
4562 signal (SIGSEGV, crash_signal);
4565 signal (SIGILL, crash_signal);
4568 signal (SIGBUS, crash_signal);
4571 signal (SIGABRT, crash_signal);
4573 #if defined SIGIOT && (!defined SIGABRT || SIGABRT != SIGIOT)
4574 signal (SIGIOT, crash_signal);
4577 signal (SIGFPE, crash_signal);
4580 /* Other host-specific signal setup. */
4581 (*host_hooks.extra_signals)();
4583 /* Initialize the diagnostics reporting machinery, so option parsing
4584 can give warnings and errors. */
4585 diagnostic_initialize (global_dc);
4587 /* Initialize the garbage-collector, string pools and tree type hash
4593 /* APPLE LOCAL setrlimit */
4595 /* Get rid of any avoidable limit on stack size. */
4599 /* Set the stack limit huge. (Compiles normally work within
4600 a megabyte of stack, but the normal limit on OSX is 512K for
4602 getrlimit (RLIMIT_STACK, &rlim);
4603 rlim.rlim_cur = rlim.rlim_max;
4604 setrlimit (RLIMIT_STACK, &rlim);
4606 #endif /* RLIMIT_STACK defined */
4609 /* Parse command line options and set default flag values, called
4610 after language-independent option-independent initialization. Do
4611 minimal options processing. Outputting diagnostics is OK, but GC
4612 and identifier hashtables etc. are not initialized yet.
4614 Return nonzero to suppress compiler back end initialization. */
4616 parse_options_and_default_flags (int argc, char **argv)
4620 /* Save in case md file wants to emit args as a comment. */
4624 /* Initialize register usage now so switches may override. */
4627 /* Register the language-independent parameters. */
4628 add_params (lang_independent_params, LAST_PARAM);
4630 /* This must be done after add_params but before argument processing. */
4631 init_ggc_heuristics();
4633 /* Perform language-specific options initialization. */
4634 lang_mask = (*lang_hooks.init_options) ();
4636 /* Scan to see what optimization level has been specified. That will
4637 determine the default value of many flags. */
4638 for (i = 1; i < argc; i++)
4640 if (!strcmp (argv[i], "-O"))
4645 else if (argv[i][0] == '-' && argv[i][1] == 'O')
4647 /* Handle -Os, -O2, -O3, -O69, ... */
4648 char *p = &argv[i][2];
4650 if ((p[0] == 's') && (p[1] == 0))
4654 /* Optimizing for size forces optimize to be 2. */
4659 const int optimize_val = read_integral_parameter (p, p - 2, -1);
4660 if (optimize_val != -1)
4662 optimize = optimize_val;
4671 flag_merge_constants = 0;
4677 flag_thread_jumps = 1;
4679 flag_delayed_branch = 1;
4681 #ifdef CAN_DEBUG_WITHOUT_FP
4682 flag_omit_frame_pointer = 1;
4684 flag_guess_branch_prob = 1;
4685 flag_cprop_registers = 1;
4686 flag_loop_optimize = 1;
4687 flag_crossjumping = 1;
4688 flag_if_conversion = 1;
4689 flag_if_conversion2 = 1;
4694 flag_optimize_sibling_calls = 1;
4695 flag_cse_follow_jumps = 1;
4696 flag_cse_skip_blocks = 1;
4698 flag_expensive_optimizations = 1;
4699 flag_strength_reduce = 1;
4700 flag_rerun_cse_after_loop = 1;
4701 flag_rerun_loop_opt = 1;
4702 flag_caller_saves = 1;
4705 #ifdef INSN_SCHEDULING
4706 flag_schedule_insns = 1;
4707 flag_schedule_insns_after_reload = 1;
4710 flag_strict_aliasing = 1;
4711 flag_delete_null_pointer_checks = 1;
4712 flag_reorder_blocks = 1;
4713 flag_reorder_functions = 1;
4718 flag_inline_functions = 1;
4719 flag_rename_registers = 1;
4720 flag_unswitch_loops = 1;
4721 flag_unit_at_a_time = 1;
4724 if (optimize < 2 || optimize_size)
4729 align_functions = 1;
4731 /* Don't reorder blocks when optimizing for size because extra
4732 jump insns may be created; also barrier may create extra padding.
4734 More correctly we should have a block reordering mode that tried
4735 to minimize the combined size of all the jumps. This would more
4736 or less automatically remove extra jumps, but would also try to
4737 use more short jumps instead of long jumps. */
4738 flag_reorder_blocks = 0;
4741 /* Initialize whether `char' is signed. */
4742 flag_signed_char = DEFAULT_SIGNED_CHAR;
4743 #ifdef DEFAULT_SHORT_ENUMS
4744 /* Initialize how much space enums occupy, by default. */
4745 flag_short_enums = DEFAULT_SHORT_ENUMS;
4748 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
4751 set_target_switch ("");
4753 /* Unwind tables are always present in an ABI-conformant IA-64
4754 object file, so the default should be ON. */
4755 #ifdef IA64_UNWIND_INFO
4756 flag_unwind_tables = IA64_UNWIND_INFO;
4759 #ifdef OPTIMIZATION_OPTIONS
4760 /* Allow default optimizations to be specified on a per-machine basis. */
4761 OPTIMIZATION_OPTIONS (optimize, optimize_size);
4764 handle_options (argc, argv, lang_mask);
4767 flag_pic = flag_pie;
4768 if (flag_pic && !flag_pie)
4771 if (flag_no_inline == 2)
4774 flag_really_no_inline = flag_no_inline;
4776 /* Set flag_no_inline before the post_options () hook. The C front
4777 ends use it to determine tree inlining defaults. FIXME: such
4778 code should be lang-independent when all front ends use tree
4779 inlining, in which case it, and this condition, should be moved
4780 to the top of process_options() instead. */
4783 /* Inlining does not work if not optimizing,
4784 so force it not to be done. */
4788 /* The c_decode_option function and decode_option hook set
4789 this to `2' if -Wall is used, so we can avoid giving out
4790 lots of errors for people who don't realize what -Wall does. */
4791 if (warn_uninitialized == 1)
4792 warning ("-Wuninitialized is not supported without -O");
4795 if (flag_really_no_inline == 2)
4796 flag_really_no_inline = flag_no_inline;
4799 /* Process the options that have been parsed. */
4801 process_options (void)
4803 /* Allow the front end to perform consistency checks and do further
4804 initialization based on the command line options. This hook also
4805 sets the original filename if appropriate (e.g. foo.i -> foo.c)
4806 so we can correctly initialize debug output. */
4807 no_backend = (*lang_hooks.post_options) (&main_input_filename);
4808 input_filename = main_input_filename;
4810 #ifdef OVERRIDE_OPTIONS
4811 /* Some machines may reject certain combinations of options. */
4815 /* Set aux_base_name if not already set. */
4818 else if (main_input_filename)
4820 char *name = xstrdup (lbasename (main_input_filename));
4822 strip_off_ending (name, strlen (name));
4823 aux_base_name = name;
4826 aux_base_name = "gccaux";
4828 /* Set up the align_*_log variables, defaulting them to 1 if they
4829 were still unset. */
4830 if (align_loops <= 0) align_loops = 1;
4831 if (align_loops_max_skip > align_loops || !align_loops)
4832 align_loops_max_skip = align_loops - 1;
4833 align_loops_log = floor_log2 (align_loops * 2 - 1);
4834 if (align_jumps <= 0) align_jumps = 1;
4835 if (align_jumps_max_skip > align_jumps || !align_jumps)
4836 align_jumps_max_skip = align_jumps - 1;
4837 align_jumps_log = floor_log2 (align_jumps * 2 - 1);
4838 if (align_labels <= 0) align_labels = 1;
4839 align_labels_log = floor_log2 (align_labels * 2 - 1);
4840 if (align_labels_max_skip > align_labels || !align_labels)
4841 align_labels_max_skip = align_labels - 1;
4842 if (align_functions <= 0) align_functions = 1;
4843 align_functions_log = floor_log2 (align_functions * 2 - 1);
4845 /* Unrolling all loops implies that standard loop unrolling must also
4847 if (flag_unroll_all_loops)
4848 flag_unroll_loops = 1;
4850 if (flag_unroll_loops)
4852 flag_old_unroll_loops = 0;
4853 flag_old_unroll_all_loops = 0;
4856 if (flag_old_unroll_all_loops)
4857 flag_old_unroll_loops = 1;
4859 /* Old loop unrolling requires that strength_reduction be on also. Silently
4860 turn on strength reduction here if it isn't already on. Also, the loop
4861 unrolling code assumes that cse will be run after loop, so that must
4862 be turned on also. */
4863 if (flag_old_unroll_loops)
4865 flag_strength_reduce = 1;
4866 flag_rerun_cse_after_loop = 1;
4868 if (flag_unroll_loops || flag_peel_loops)
4869 flag_rerun_cse_after_loop = 1;
4871 if (flag_non_call_exceptions)
4872 flag_asynchronous_unwind_tables = 1;
4873 if (flag_asynchronous_unwind_tables)
4874 flag_unwind_tables = 1;
4876 /* Disable unit-at-a-time mode for frontends not supporting callgraph
4878 if (flag_unit_at_a_time && ! lang_hooks.callgraph.expand_function)
4879 flag_unit_at_a_time = 0;
4881 /* Warn about options that are not supported on this machine. */
4882 #ifndef INSN_SCHEDULING
4883 if (flag_schedule_insns || flag_schedule_insns_after_reload)
4884 warning ("instruction scheduling not supported on this target machine");
4887 if (flag_delayed_branch)
4888 warning ("this target machine does not have delayed branches");
4891 user_label_prefix = USER_LABEL_PREFIX;
4892 if (flag_leading_underscore != -1)
4894 /* If the default prefix is more complicated than "" or "_",
4895 issue a warning and ignore this option. */
4896 if (user_label_prefix[0] == 0 ||
4897 (user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
4899 user_label_prefix = flag_leading_underscore ? "_" : "";
4902 warning ("-f%sleading-underscore not supported on this target machine",
4903 flag_leading_underscore ? "" : "no-");
4906 /* If we are in verbose mode, write out the version and maybe all the
4907 option flags in use. */
4910 print_version (stderr, "");
4912 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
4915 if (flag_syntax_only)
4917 write_symbols = NO_DEBUG;
4921 /* Now we know write_symbols, set up the debug hooks based on it.
4922 By default we do nothing for debug output. */
4923 #if defined(DBX_DEBUGGING_INFO)
4924 if (write_symbols == DBX_DEBUG)
4925 debug_hooks = &dbx_debug_hooks;
4927 #if defined(XCOFF_DEBUGGING_INFO)
4928 if (write_symbols == XCOFF_DEBUG)
4929 debug_hooks = &xcoff_debug_hooks;
4931 #ifdef SDB_DEBUGGING_INFO
4932 if (write_symbols == SDB_DEBUG)
4933 debug_hooks = &sdb_debug_hooks;
4935 #ifdef DWARF_DEBUGGING_INFO
4936 if (write_symbols == DWARF_DEBUG)
4937 debug_hooks = &dwarf_debug_hooks;
4939 #ifdef DWARF2_DEBUGGING_INFO
4940 if (write_symbols == DWARF2_DEBUG)
4941 debug_hooks = &dwarf2_debug_hooks;
4943 #ifdef VMS_DEBUGGING_INFO
4944 if (write_symbols == VMS_DEBUG || write_symbols == VMS_AND_DWARF2_DEBUG)
4945 debug_hooks = &vmsdbg_debug_hooks;
4948 /* If auxiliary info generation is desired, open the output file.
4949 This goes in the same directory as the source file--unlike
4950 all the other output files. */
4951 if (flag_gen_aux_info)
4953 aux_info_file = fopen (aux_info_file_name, "w");
4954 if (aux_info_file == 0)
4955 fatal_error ("can't open %s: %m", aux_info_file_name);
4958 if (! targetm.have_named_sections)
4960 if (flag_function_sections)
4962 warning ("-ffunction-sections not supported for this target");
4963 flag_function_sections = 0;
4965 if (flag_data_sections)
4967 warning ("-fdata-sections not supported for this target");
4968 flag_data_sections = 0;
4972 if (flag_function_sections && profile_flag)
4974 warning ("-ffunction-sections disabled; it makes profiling impossible");
4975 flag_function_sections = 0;
4978 #ifndef HAVE_prefetch
4979 if (flag_prefetch_loop_arrays)
4981 warning ("-fprefetch-loop-arrays not supported for this target");
4982 flag_prefetch_loop_arrays = 0;
4985 if (flag_prefetch_loop_arrays && !HAVE_prefetch)
4987 warning ("-fprefetch-loop-arrays not supported for this target (try -march switches)");
4988 flag_prefetch_loop_arrays = 0;
4992 /* This combination of options isn't handled for i386 targets and doesn't
4993 make much sense anyway, so don't allow it. */
4994 if (flag_prefetch_loop_arrays && optimize_size)
4996 warning ("-fprefetch-loop-arrays is not supported with -Os");
4997 flag_prefetch_loop_arrays = 0;
5000 #ifndef OBJECT_FORMAT_ELF
5001 if (flag_function_sections && write_symbols != NO_DEBUG)
5002 warning ("-ffunction-sections may affect debugging on some targets");
5005 /* The presence of IEEE signaling NaNs, implies all math can trap. */
5006 if (flag_signaling_nans)
5007 flag_trapping_math = 1;
5010 /* Initialize the compiler back end. */
5014 /* init_emit_once uses reg_raw_mode and therefore must be called
5015 after init_regs which initialized reg_raw_mode. */
5017 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
5018 || debug_info_level == DINFO_LEVEL_VERBOSE
5019 #ifdef VMS_DEBUGGING_INFO
5020 /* Enable line number info for traceback */
5021 || debug_info_level > DINFO_LEVEL_NONE
5023 || flag_test_coverage
5024 || warn_notreached);
5025 init_fake_stack_mems ();
5029 init_function_once ();
5030 init_varasm_once ();
5032 /* The following initialization functions need to generate rtl, so
5033 provide a dummy function context for them. */
5034 init_dummy_function_start ();
5036 if (flag_caller_saves)
5037 init_caller_save ();
5038 expand_dummy_function_end ();
5041 /* Language-dependent initialization. Returns nonzero on success. */
5043 lang_dependent_init (const char *name)
5045 if (dump_base_name == 0)
5046 dump_base_name = name ? name : "gccdump";
5048 /* Other front-end initialization. */
5049 if ((*lang_hooks.init) () == 0)
5052 init_asm_output (name);
5054 /* These create various _DECL nodes, so need to be called after the
5055 front end is initialized. */
5059 /* The following initialization functions need to generate rtl, so
5060 provide a dummy function context for them. */
5061 init_dummy_function_start ();
5063 expand_dummy_function_end ();
5065 /* If dbx symbol table desired, initialize writing it and output the
5066 predefined types. */
5067 timevar_push (TV_SYMOUT);
5069 #ifdef DWARF2_UNWIND_INFO
5070 if (dwarf2out_do_frame ())
5071 dwarf2out_frame_init ();
5074 /* Now we have the correct original filename, we can initialize
5076 (*debug_hooks->init) (name);
5078 timevar_pop (TV_SYMOUT);
5083 /* Clean up: close opened files, etc. */
5088 /* Close the dump files. */
5089 if (flag_gen_aux_info)
5091 fclose (aux_info_file);
5093 unlink (aux_info_file_name);
5096 /* Close non-debugging input and output files. Take special care to note
5097 whether fclose returns an error, since the pages might still be on the
5098 buffer chain while the file is open. */
5102 if (ferror (asm_out_file) != 0)
5103 fatal_error ("error writing to %s: %m", asm_file_name);
5104 if (fclose (asm_out_file) != 0)
5105 fatal_error ("error closing %s: %m", asm_file_name);
5108 /* Do whatever is necessary to finish printing the graphs. */
5109 if (graph_dump_format != no_graph)
5113 for (i = 0; i < (int) DFI_MAX; ++i)
5114 if (dump_file[i].initialized && dump_file[i].graph_dump_p)
5119 sprintf (seq, DUMPFILE_FORMAT, i);
5120 suffix = concat (seq, dump_file[i].extension, NULL);
5121 finish_graph_dump_file (dump_base_name, suffix);
5128 ggc_print_statistics ();
5129 stringpool_statistics ();
5130 dump_tree_statistics ();
5133 /* Free up memory for the benefit of leak detectors. */
5136 /* Language-specific end of compilation actions. */
5137 (*lang_hooks.finish) ();
5140 /* Initialize the compiler, and compile the input file. */
5144 /* Initialize timing first. The C front ends read the main file in
5145 the post_options hook, and C++ does file timings. */
5146 if (time_report || !quiet_flag || flag_detailed_statistics)
5148 timevar_start (TV_TOTAL);
5152 /* Don't do any more if an error has already occurred. */
5155 /* Set up the back-end if requested. */
5159 /* Language-dependent initialization. Returns true on success. */
5160 if (lang_dependent_init (main_input_filename))
5166 /* Stop timing and print the times. */
5167 timevar_stop (TV_TOTAL);
5168 timevar_print (stderr);
5171 /* Entry point of cc1, cc1plus, jc1, f771, etc.
5172 Decode command args, then call compile_file.
5173 Exit code is FATAL_EXIT_CODE if can't open files or if there were
5174 any errors, or SUCCESS_EXIT_CODE if compilation succeeded.
5176 It is not safe to call this function more than once. */
5179 toplev_main (int argc, char **argv)
5181 /* Initialization of GCC's environment, and diagnostics. */
5182 general_init (argv[0]);
5184 /* Parse the options and do minimal processing; basically just
5185 enough to default flags appropriately. */
5186 parse_options_and_default_flags (argc, argv);
5188 /* Exit early if we can (e.g. -help). */
5189 if (!exit_after_options)
5192 if (errorcount || sorrycount)
5193 return (FATAL_EXIT_CODE);
5195 return (SUCCESS_EXIT_CODE);