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 (const char *);
108 static void do_compile (void);
109 static void process_options (void);
110 static void backend_init (void);
111 static int lang_dependent_init (const char *);
112 static void init_asm_output (const char *);
113 static void finalize (void);
115 static void crash_signal (int) ATTRIBUTE_NORETURN;
116 static void setup_core_dumping (void);
117 static void compile_file (void);
119 static int print_single_switch (FILE *, int, int, const char *,
120 const char *, const char *,
121 const char *, const char *);
122 static void print_switch_values (FILE *, int, int, const char *,
123 const char *, const char *);
125 /* Rest of compilation helper functions. */
126 static bool rest_of_handle_inlining (tree);
127 static rtx rest_of_handle_ssa (tree, rtx);
128 static void rest_of_handle_cse (tree, rtx);
129 static void rest_of_handle_cse2 (tree, rtx);
130 static void rest_of_handle_gcse (tree, rtx);
131 static void rest_of_handle_life (tree, rtx);
132 static void rest_of_handle_loop_optimize (tree, rtx);
133 static void rest_of_handle_loop2 (tree, rtx);
134 static void rest_of_handle_jump_bypass (tree, rtx);
135 static void rest_of_handle_sibling_calls (rtx);
136 static void rest_of_handle_null_pointer (tree, rtx);
137 static void rest_of_handle_addresof (tree, rtx);
138 static void rest_of_handle_cfg (tree, rtx);
139 static void rest_of_handle_branch_prob (tree, rtx);
140 static void rest_of_handle_if_conversion (tree, rtx);
141 static void rest_of_handle_if_after_combine (tree, rtx);
142 static void rest_of_handle_tracer (tree, rtx);
143 static void rest_of_handle_combine (tree, rtx);
144 static void rest_of_handle_regmove (tree, rtx);
145 #ifdef INSN_SCHEDULING
146 static void rest_of_handle_sched (tree, rtx);
147 static void rest_of_handle_sched2 (tree, rtx);
149 static bool rest_of_handle_new_regalloc (tree, rtx, int *);
150 static bool rest_of_handle_old_regalloc (tree, rtx, int *);
151 static void rest_of_handle_regrename (tree, rtx);
152 static void rest_of_handle_reorder_blocks (tree, rtx);
154 static void rest_of_handle_stack_regs (tree, rtx);
156 static void rest_of_handle_machine_reorg (tree, rtx);
158 static void rest_of_handle_delay_slots (tree, rtx);
160 static void rest_of_handle_final (tree, rtx);
162 /* Nonzero to dump debug info whilst parsing (-dy option). */
163 static int set_yydebug;
165 /* True if we don't need a backend (e.g. preprocessing only). */
166 static bool no_backend;
168 /* Length of line when printing switch values. */
171 /* Name of program invoked, sans directories. */
173 const char *progname;
175 /* Copy of argument vector to toplev_main. */
176 static const char **save_argv;
178 /* Name of top-level original source file (what was input to cpp).
179 This comes from the #-command at the beginning of the actual input.
180 If there isn't any there, then this is the cc1 input file name. */
182 const char *main_input_filename;
184 /* Current position in real source file. */
186 location_t input_location;
188 /* Nonzero if it is unsafe to create any new pseudo registers. */
191 /* Stack of currently pending input files. */
193 struct file_stack *input_file_stack;
195 /* Incremented on each change to input_file_stack. */
196 int input_file_stack_tick;
198 /* Name to use as base of names for dump output files. */
200 const char *dump_base_name;
202 /* Name to use as a base for auxiliary output files. */
204 const char *aux_base_name;
206 /* Format to use to print dumpfile index value */
207 #ifndef DUMPFILE_FORMAT
208 #define DUMPFILE_FORMAT ".%02d."
211 /* Bit flags that specify the machine subtype we are compiling for.
212 Bits are tested using macros TARGET_... defined in the tm.h file
213 and set by `-m...' switches. Must be defined in rtlanal.c. */
215 extern int target_flags;
217 /* A mask of target_flags that includes bit X if X was set or cleared
218 on the command line. */
220 int target_flags_explicit;
222 /* Debug hooks - dependent upon command line options. */
224 const struct gcc_debug_hooks *debug_hooks = &do_nothing_debug_hooks;
226 /* Describes a dump file. */
228 struct dump_file_info
230 /* The unique extension to apply, e.g. ".jump". */
231 const char *const extension;
233 /* The -d<c> character that enables this dump file. */
234 char const debug_switch;
236 /* True if there is a corresponding graph dump file. */
237 char const graph_dump_p;
239 /* True if the user selected this dump. */
242 /* True if the files have been initialized (ie truncated). */
246 /* Enumerate the extant dump files. */
283 DFI_branch_target_load,
291 /* Describes all the dump files. Should be kept in order of the
292 pass and in sync with dump_file_index above.
294 Remaining -d letters:
300 static struct dump_file_info dump_file[DFI_MAX] =
302 { "rtl", 'r', 0, 0, 0 },
303 { "sibling", 'i', 0, 0, 0 },
304 { "eh", 'h', 0, 0, 0 },
305 { "jump", 'j', 0, 0, 0 },
306 { "ssa", 'e', 1, 0, 0 },
307 { "ssaccp", 'W', 1, 0, 0 },
308 { "ssadce", 'X', 1, 0, 0 },
309 { "ussa", 'e', 1, 0, 0 }, /* Yes, duplicate enable switch. */
310 { "null", 'u', 0, 0, 0 },
311 { "cse", 's', 0, 0, 0 },
312 { "addressof", 'F', 0, 0, 0 },
313 { "gcse", 'G', 1, 0, 0 },
314 { "loop", 'L', 1, 0, 0 },
315 { "bypass", 'G', 1, 0, 0 }, /* Yes, duplicate enable switch. */
316 { "cfg", 'f', 1, 0, 0 },
317 { "bp", 'b', 1, 0, 0 },
318 { "ce1", 'C', 1, 0, 0 },
319 { "tracer", 'T', 1, 0, 0 },
320 { "loop2", 'L', 1, 0, 0 },
321 { "cse2", 't', 1, 0, 0 },
322 { "life", 'f', 1, 0, 0 }, /* Yes, duplicate enable switch. */
323 { "combine", 'c', 1, 0, 0 },
324 { "ce2", 'C', 1, 0, 0 },
325 { "regmove", 'N', 1, 0, 0 },
326 { "sched", 'S', 1, 0, 0 },
327 { "lreg", 'l', 1, 0, 0 },
328 { "greg", 'g', 1, 0, 0 },
329 { "postreload", 'o', 1, 0, 0 },
330 { "flow2", 'w', 1, 0, 0 },
331 { "peephole2", 'z', 1, 0, 0 },
332 { "rnreg", 'n', 1, 0, 0 },
333 { "bbro", 'B', 1, 0, 0 },
334 { "ce3", 'E', 1, 0, 0 },
335 { "btl", 'd', 1, 0, 0 }, /* Yes, duplicate enable switch. */
336 { "sched2", 'R', 1, 0, 0 },
337 { "stack", 'k', 1, 0, 0 },
338 { "mach", 'M', 1, 0, 0 },
339 { "dbr", 'd', 0, 0, 0 },
342 static int open_dump_file (enum dump_file_index, tree);
343 static void close_dump_file (enum dump_file_index,
344 void (*) (FILE *, rtx), rtx);
346 /* Other flags saying which kinds of debugging dump have been requested. */
348 int rtl_dump_and_exit;
349 int flag_print_asm_name;
350 enum graph_dump_types graph_dump_format;
352 /* Name for output file of assembly code, specified with -o. */
354 const char *asm_file_name;
356 /* Type(s) of debugging information we are producing (if any).
357 See flags.h for the definitions of the different possible
358 types of debugging information. */
359 enum debug_info_type write_symbols = NO_DEBUG;
361 /* Level of debugging information we are producing. See flags.h
362 for the definitions of the different possible levels. */
363 enum debug_info_level debug_info_level = DINFO_LEVEL_NONE;
365 /* Nonzero means use GNU-only extensions in the generated symbolic
366 debugging information. */
367 /* Currently, this only has an effect when write_symbols is set to
368 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
369 int use_gnu_debug_info_extensions = 0;
371 /* Nonzero means do optimizations. -O.
372 Particular numeric values stand for particular amounts of optimization;
373 thus, -O2 stores 2 here. However, the optimizations beyond the basic
374 ones are not controlled directly by this variable. Instead, they are
375 controlled by individual `flag_...' variables that are defaulted
376 based on this variable. */
380 /* Nonzero means optimize for size. -Os.
381 The only valid values are zero and nonzero. When optimize_size is
382 nonzero, optimize defaults to 2, but certain individual code
383 bloating optimizations are disabled. */
385 int optimize_size = 0;
387 /* The FUNCTION_DECL for the function currently being compiled,
388 or 0 if between functions. */
389 tree current_function_decl;
391 /* Set to the FUNC_BEGIN label of the current function, or NULL_TREE
393 tree current_function_func_begin_label;
395 /* Nonzero if doing dwarf2 duplicate elimination. */
397 int flag_eliminate_dwarf2_dups = 0;
399 /* Nonzero if doing unused type elimination. */
401 int flag_eliminate_unused_debug_types = 1;
403 /* Nonzero means emit debugging information only for symbols which are used. */
404 int flag_debug_only_used_symbols = 0;
406 /* Nonzero if generating code to do profiling. */
408 int profile_flag = 0;
410 /* Nonzero if generating code to profile program flow graph arcs. */
412 int profile_arc_flag = 0;
414 /* Nonzero if value histograms should be measured. */
416 int flag_profile_values = 0;
418 /* Nonzero if generating info for gcov to calculate line test coverage. */
420 int flag_test_coverage = 0;
422 /* Nonzero indicates that branch taken probabilities should be calculated. */
424 int flag_branch_probabilities = 0;
426 /* Nonzero if basic blocks should be reordered. */
428 int flag_reorder_blocks = 0;
430 /* Nonzero if functions should be reordered. */
432 int flag_reorder_functions = 0;
434 /* Nonzero if registers should be renamed. */
436 int flag_rename_registers = 0;
437 int flag_cprop_registers = 0;
439 /* Nonzero for -pedantic switch: warn about anything
440 that standard spec forbids. */
444 /* Temporarily suppress certain warnings.
445 This is set while reading code from a system header file. */
447 int in_system_header = 0;
449 /* Don't print functions as they are compiled. -quiet. */
453 /* Print times taken by the various passes. -ftime-report. */
457 /* Print memory still in use at end of compilation (which may have little
458 to do with peak memory consumption). -fmem-report. */
462 /* Nonzero means to collect statistics which might be expensive
463 and to print them when we are done. */
464 int flag_detailed_statistics = 0;
466 /* A random sequence of characters, unless overridden by user. */
467 const char *flag_random_seed;
469 /* A local time stamp derived from the time of compilation. It will be
470 zero if the system cannot provide a time. It will be -1u, if the
471 user has specified a particular random seed. */
476 /* Nonzero means `char' should be signed. */
478 int flag_signed_char;
480 /* Nonzero means give an enum type only as many bytes as it needs. */
482 int flag_short_enums;
484 /* Nonzero for -fcaller-saves: allocate values in regs that need to
485 be saved across function calls, if that produces overall better code.
486 Optional now, so people can test it. */
488 #ifdef DEFAULT_CALLER_SAVES
489 int flag_caller_saves = 1;
491 int flag_caller_saves = 0;
494 /* Nonzero if structures and unions should be returned in memory.
496 This should only be defined if compatibility with another compiler or
497 with an ABI is needed, because it results in slower code. */
499 #ifndef DEFAULT_PCC_STRUCT_RETURN
500 #define DEFAULT_PCC_STRUCT_RETURN 1
503 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
505 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
507 /* Nonzero for -fforce-mem: load memory value into a register
508 before arithmetic on it. This makes better cse but slower compilation. */
510 int flag_force_mem = 0;
512 /* Nonzero for -fforce-addr: load memory address into a register before
513 reference to memory. This makes better cse but slower compilation. */
515 int flag_force_addr = 0;
517 /* Nonzero for -fdefer-pop: don't pop args after each function call;
518 instead save them up to pop many calls' args with one insns. */
520 int flag_defer_pop = 0;
522 /* Nonzero for -ffloat-store: don't allocate floats and doubles
523 in extended-precision registers. */
525 int flag_float_store = 0;
527 /* Nonzero for -fcse-follow-jumps:
528 have cse follow jumps to do a more extensive job. */
530 int flag_cse_follow_jumps;
532 /* Nonzero for -fcse-skip-blocks:
533 have cse follow a branch around a block. */
534 int flag_cse_skip_blocks;
536 /* Nonzero for -fexpensive-optimizations:
537 perform miscellaneous relatively-expensive optimizations. */
538 int flag_expensive_optimizations;
540 /* Nonzero for -fthread-jumps:
541 have jump optimize output of loop. */
543 int flag_thread_jumps;
545 /* Nonzero enables strength-reduction in loop.c. */
547 int flag_strength_reduce = 0;
549 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
550 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
551 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
554 int flag_old_unroll_loops;
556 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
557 This is generally not a win. */
559 int flag_old_unroll_all_loops;
561 /* Enables unrolling of simple loops in loop-unroll.c. */
562 int flag_unroll_loops;
564 /* Enables unrolling of all loops in loop-unroll.c. */
565 int flag_unroll_all_loops;
567 /* Nonzero enables loop peeling. */
570 /* Nonzero enables loop unswitching. */
571 int flag_unswitch_loops;
573 /* Nonzero enables prefetch optimizations for arrays in loops. */
575 int flag_prefetch_loop_arrays;
577 /* Nonzero forces all invariant computations in loops to be moved
580 int flag_move_all_movables = 0;
582 /* Nonzero forces all general induction variables in loops to be
585 int flag_reduce_all_givs = 0;
587 /* Nonzero to perform full register move optimization passes. This is the
590 int flag_regmove = 0;
592 /* Nonzero for -fwritable-strings:
593 store string constants in data segment and don't uniquize them. */
595 int flag_writable_strings = 0;
597 /* Nonzero means don't put addresses of constant functions in registers.
598 Used for compiling the Unix kernel, where strange substitutions are
599 done on the assembly output. */
601 int flag_no_function_cse = 0;
603 /* Nonzero for -fomit-frame-pointer:
604 don't make a frame pointer in simple functions that don't require one. */
606 int flag_omit_frame_pointer = 0;
608 /* Nonzero means place each function into its own section on those platforms
609 which support arbitrary section names and unlimited numbers of sections. */
611 int flag_function_sections = 0;
613 /* ... and similar for data. */
615 int flag_data_sections = 0;
617 /* Nonzero to inhibit use of define_optimization peephole opts. */
619 int flag_no_peephole = 0;
621 /* Nonzero allows GCC to optimize sibling and tail recursive calls. */
623 int flag_optimize_sibling_calls = 0;
625 /* Nonzero means the front end generally wants `errno' maintained by math
626 operations, like built-in SQRT. */
628 int flag_errno_math = 1;
630 /* Nonzero means that unsafe floating-point math optimizations are allowed
631 for the sake of speed. IEEE compliance is not guaranteed, and operations
632 are allowed to assume that their arguments and results are "normal"
633 (e.g., nonnegative for SQRT). */
635 int flag_unsafe_math_optimizations = 0;
637 /* Nonzero means that no NaNs or +-Infs are expected. */
639 int flag_finite_math_only = 0;
641 /* Zero means that floating-point math operations cannot generate a
642 (user-visible) trap. This is the case, for example, in nonstop
643 IEEE 754 arithmetic. Trapping conditions include division by zero,
644 overflow, underflow, invalid and inexact, but does not include
645 operations on signaling NaNs (see below). */
647 int flag_trapping_math = 1;
649 /* Nonzero means disable transformations observable by signaling NaNs.
650 This option implies that any operation on an IEEE signaling NaN can
651 generate a (user-visible) trap. */
653 int flag_signaling_nans = 0;
655 /* 0 means straightforward implementation of complex divide acceptable.
656 1 means wide ranges of inputs must work for complex divide.
657 2 means C99-like requirements for complex divide (not yet implemented). */
659 int flag_complex_divide_method = 0;
661 /* Nonzero means just do syntax checking; don't output anything. */
663 int flag_syntax_only = 0;
665 /* Nonzero means perform loop optimizer. */
667 int flag_loop_optimize;
669 /* Nonzero means perform crossjumping. */
671 int flag_crossjumping;
673 /* Nonzero means perform if conversion. */
675 int flag_if_conversion;
677 /* Nonzero means perform if conversion after reload. */
679 int flag_if_conversion2;
681 /* Nonzero means to use global dataflow analysis to eliminate
682 useless null pointer tests. */
684 int flag_delete_null_pointer_checks;
686 /* Nonzero means perform global CSE. */
690 /* Nonzero means to do the enhanced load motion during gcse, which trys
691 to hoist loads by not killing them when a store to the same location
694 int flag_gcse_lm = 1;
696 /* Nonzero means to perform store motion after gcse, which will try to
697 move stores closer to the exit block. Its not very effective without
700 int flag_gcse_sm = 1;
702 /* Perform target register optimization before prologue / epilogue
705 int flag_branch_target_load_optimize = 0;
707 /* Perform target register optimization after prologue / epilogue
708 threading and jump2. */
710 int flag_branch_target_load_optimize2 = 0;
712 /* Nonzero means to rerun cse after loop optimization. This increases
713 compilation time about 20% and picks up a few more common expressions. */
715 int flag_rerun_cse_after_loop;
717 /* Nonzero means to run loop optimizations twice. */
719 int flag_rerun_loop_opt;
721 /* Nonzero for -finline-functions: ok to inline functions that look like
722 good inline candidates. */
724 int flag_inline_functions;
726 /* Nonzero for -fkeep-inline-functions: even if we make a function
727 go inline everywhere, keep its definition around for debugging
730 int flag_keep_inline_functions;
732 /* Nonzero means that functions will not be inlined. */
734 int flag_no_inline = 2;
736 /* Nonzero means that we don't want inlining by virtue of -fno-inline,
737 not just because the tree inliner turned us off. */
739 int flag_really_no_inline = 2;
741 /* Nonzero means that we should emit static const variables
742 regardless of whether or not optimization is turned on. */
744 int flag_keep_static_consts = 1;
746 /* Nonzero means we should be saving declaration info into a .X file. */
748 int flag_gen_aux_info = 0;
750 /* Specified name of aux-info file. */
752 const char *aux_info_file_name;
754 /* Nonzero means make the text shared if supported. */
756 int flag_shared_data;
758 /* Nonzero means schedule into delayed branch slots if supported. */
760 int flag_delayed_branch;
762 /* Nonzero if we are compiling pure (sharable) code.
763 Value is 1 if we are doing "small" pic; value is 2 if we're doing
768 /* Nonzero if we are compiling position independent code for executable.
769 The value is 1 if we are doing "small" pic; value is 2 if we're doing
774 /* Nonzero if we are compiling code for a shared library, zero for
779 /* Set to the default thread-local storage (tls) model to use. */
781 enum tls_model flag_tls_default = TLS_MODEL_GLOBAL_DYNAMIC;
783 /* Nonzero means generate extra code for exception handling and enable
784 exception handling. */
788 /* Nonzero means generate frame unwind info table when supported. */
790 int flag_unwind_tables = 0;
792 /* Nonzero means generate frame unwind info table exact at each insn
795 int flag_asynchronous_unwind_tables = 0;
797 /* Nonzero means don't place uninitialized global data in common storage
802 /* Nonzero means change certain warnings into errors.
803 Usually these are warnings about failure to conform to some standard. */
805 int flag_pedantic_errors = 0;
807 /* flag_schedule_insns means schedule insns within basic blocks (before
809 flag_schedule_insns_after_reload means schedule insns after
812 int flag_schedule_insns = 0;
813 int flag_schedule_insns_after_reload = 0;
815 /* When flag_schedule_insns_after_reload is set, use EBB scheduler. */
816 int flag_sched2_use_superblocks = 0;
818 /* When flag_schedule_insns_after_reload is set, construct traces and EBB
820 int flag_sched2_use_traces = 0;
822 /* The following flags have effect only for scheduling before register
825 flag_schedule_interblock means schedule insns across basic blocks.
826 flag_schedule_speculative means allow speculative motion of non-load insns.
827 flag_schedule_speculative_load means allow speculative motion of some
829 flag_schedule_speculative_load_dangerous allows speculative motion of more
832 int flag_schedule_interblock = 1;
833 int flag_schedule_speculative = 1;
834 int flag_schedule_speculative_load = 0;
835 int flag_schedule_speculative_load_dangerous = 0;
837 int flag_single_precision_constant;
839 /* flag_branch_on_count_reg means try to replace add-1,compare,branch tupple
840 by a cheaper branch on a count register. */
841 int flag_branch_on_count_reg = 1;
843 /* -finhibit-size-directive inhibits output of .size for ELF.
844 This is used only for compiling crtstuff.c,
845 and it may be extended to other effects
846 needed for crtstuff.c on other systems. */
847 int flag_inhibit_size_directive = 0;
849 /* -fverbose-asm causes extra commentary information to be produced in
850 the generated assembly code (to make it more readable). This option
851 is generally only of use to those who actually need to read the
852 generated assembly code (perhaps while debugging the compiler itself).
853 -fno-verbose-asm, the default, causes the extra information
854 to be omitted and is useful when comparing two assembler files. */
856 int flag_verbose_asm = 0;
858 /* -dA causes debug commentary information to be produced in
859 the generated assembly code (to make it more readable). This option
860 is generally only of use to those who actually need to read the
861 generated assembly code (perhaps while debugging the compiler itself).
862 Currently, this switch is only used by dwarfout.c; however, it is intended
863 to be a catchall for printing debug information in the assembler file. */
865 int flag_debug_asm = 0;
867 /* -dP causes the rtl to be emitted as a comment in assembly. */
869 int flag_dump_rtl_in_asm = 0;
871 /* -fgnu-linker specifies use of the GNU linker for initializations.
872 (Or, more generally, a linker that handles initializations.)
873 -fno-gnu-linker says that collect2 will be used. */
875 int flag_gnu_linker = 0;
877 int flag_gnu_linker = 1;
880 /* Nonzero means put zero initialized data in the bss section. */
881 int flag_zero_initialized_in_bss = 1;
886 /* Enable ssa conditional constant propagation. */
887 int flag_ssa_ccp = 0;
889 /* Enable ssa aggressive dead code elimination. */
890 int flag_ssa_dce = 0;
892 /* Tag all structures with __attribute__(packed). */
893 int flag_pack_struct = 0;
895 /* Emit code to check for stack overflow; also may cause large objects
896 to be allocated dynamically. */
897 int flag_stack_check;
899 /* When non-NULL, indicates that whenever space is allocated on the
900 stack, the resulting stack pointer must not pass this
901 address---that is, for stacks that grow downward, the stack pointer
902 must always be greater than or equal to this address; for stacks
903 that grow upward, the stack pointer must be less than this address.
904 At present, the rtx may be either a REG or a SYMBOL_REF, although
905 the support provided depends on the backend. */
908 /* 0 if pointer arguments may alias each other. True in C.
909 1 if pointer arguments may not alias each other but may alias
911 2 if pointer arguments may not alias each other and may not
912 alias global variables. True in Fortran.
913 This defaults to 0 for C. */
914 int flag_argument_noalias = 0;
916 /* Nonzero if we should do (language-dependent) alias analysis.
917 Typically, this analysis will assume that expressions of certain
918 types do not alias expressions of certain other types. Only used
919 if alias analysis (in general) is enabled. */
920 int flag_strict_aliasing = 0;
922 /* Instrument functions with calls at entry and exit, for profiling. */
923 int flag_instrument_function_entry_exit = 0;
925 /* Nonzero means ignore `#ident' directives. 0 means handle them.
926 On SVR4 targets, it also controls whether or not to emit a
927 string identifying the compiler. */
929 int flag_no_ident = 0;
931 /* This will perform a peephole pass before sched2. */
932 int flag_peephole2 = 0;
934 /* This will try to guess branch probabilities. */
935 int flag_guess_branch_prob = 0;
937 /* -fcheck-bounds causes gcc to generate array bounds checks.
938 For C, C++, ObjC: defaults to off.
939 For Java: defaults to on.
940 For Fortran: defaults to off. */
941 int flag_bounds_check = 0;
943 /* This will attempt to merge constant section constants, if 1 only
944 string constants and constants from constant pool, if 2 also constant
946 int flag_merge_constants = 1;
948 /* If one, renumber instruction UIDs to reduce the number of
949 unused UIDs if there are a lot of instructions. If greater than
950 one, unconditionally renumber instruction UIDs. */
951 int flag_renumber_insns = 1;
953 /* If nonzero, use the graph coloring register allocator. */
954 int flag_new_regalloc = 0;
956 /* Nonzero if we perform superblock formation. */
960 /* Nonzero if we perform whole unit at a time compilation. */
962 int flag_unit_at_a_time = 0;
964 /* Values of the -falign-* flags: how much to align labels in code.
965 0 means `use default', 1 means `don't align'.
966 For each variable, there is an _log variant which is the power
967 of two not less than the variable, for .align output. */
971 int align_loops_max_skip;
974 int align_jumps_max_skip;
976 int align_labels_log;
977 int align_labels_max_skip;
979 int align_functions_log;
981 /* Like align_functions_log above, but used by front-ends to force the
982 minimum function alignment. Zero means no alignment is forced. */
983 int force_align_functions_log;
985 /* Table of supported debugging formats. */
988 const char *const arg;
989 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a
990 constant expression, we use NO_DEBUG in its place. */
991 const enum debug_info_type debug_type;
992 const int use_extensions_p;
993 const char *const description;
997 { "", NO_DEBUG, DEFAULT_GDB_EXTENSIONS,
998 N_("Generate debugging info in default format") },
999 { "gdb", NO_DEBUG, 1, N_("Generate debugging info in default extended format") },
1000 #ifdef DBX_DEBUGGING_INFO
1001 { "stabs", DBX_DEBUG, 0, N_("Generate STABS format debug info") },
1002 { "stabs+", DBX_DEBUG, 1, N_("Generate extended STABS format debug info") },
1004 #ifdef DWARF_DEBUGGING_INFO
1005 { "dwarf", DWARF_DEBUG, 0, N_("Generate DWARF-1 format debug info") },
1006 { "dwarf+", DWARF_DEBUG, 1,
1007 N_("Generate extended DWARF-1 format debug info") },
1009 #ifdef DWARF2_DEBUGGING_INFO
1010 { "dwarf-2", DWARF2_DEBUG, 0, N_("Generate DWARF-2 debug info") },
1012 #ifdef XCOFF_DEBUGGING_INFO
1013 { "xcoff", XCOFF_DEBUG, 0, N_("Generate XCOFF format debug info") },
1014 { "xcoff+", XCOFF_DEBUG, 1, N_("Generate extended XCOFF format debug info") },
1016 #ifdef SDB_DEBUGGING_INFO
1017 { "coff", SDB_DEBUG, 0, N_("Generate COFF format debug info") },
1019 #ifdef VMS_DEBUGGING_INFO
1020 { "vms", VMS_DEBUG, 0, N_("Generate VMS format debug info") },
1027 const char *const string;
1028 int *const variable;
1030 const char *const description;
1032 lang_independent_options;
1034 /* Nonzero if signed arithmetic overflow should trap. */
1037 /* Nonzero if signed arithmetic overflow should wrap around. */
1040 /* Add or remove a leading underscore from user symbols. */
1041 int flag_leading_underscore = -1;
1043 /* The user symbol prefix after having resolved same. */
1044 const char *user_label_prefix;
1046 static const param_info lang_independent_params[] = {
1047 #define DEFPARAM(ENUM, OPTION, HELP, DEFAULT) \
1048 { OPTION, DEFAULT, HELP },
1049 #include "params.def"
1054 /* Table of language-independent -f options.
1055 STRING is the option name. VARIABLE is the address of the variable.
1056 ON_VALUE is the value to store in VARIABLE
1057 if `-fSTRING' is seen as an option.
1058 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
1060 static const lang_independent_options f_options[] =
1062 {"eliminate-dwarf2-dups", &flag_eliminate_dwarf2_dups, 1,
1063 N_("Perform DWARF2 duplicate elimination") },
1064 {"eliminate-unused-debug-symbols", &flag_debug_only_used_symbols, 1,
1065 N_("Perform unused type elimination in debug info") },
1066 {"eliminate-unused-debug-types", &flag_eliminate_unused_debug_types, 1,
1067 N_("Perform unused type elimination in debug info") },
1068 {"float-store", &flag_float_store, 1,
1069 N_("Do not store floats in registers") },
1070 {"defer-pop", &flag_defer_pop, 1,
1071 N_("Defer popping functions args from stack until later") },
1072 {"omit-frame-pointer", &flag_omit_frame_pointer, 1,
1073 N_("When possible do not generate stack frames") },
1074 {"optimize-sibling-calls", &flag_optimize_sibling_calls, 1,
1075 N_("Optimize sibling and tail recursive calls") },
1076 {"tracer", &flag_tracer, 1,
1077 N_("Perform superblock formation via tail duplication") },
1078 {"unit-at-a-time", &flag_unit_at_a_time, 1,
1079 N_("Compile whole compilation unit at a time") },
1080 {"cse-follow-jumps", &flag_cse_follow_jumps, 1,
1081 N_("When running CSE, follow jumps to their targets") },
1082 {"cse-skip-blocks", &flag_cse_skip_blocks, 1,
1083 N_("When running CSE, follow conditional jumps") },
1084 {"expensive-optimizations", &flag_expensive_optimizations, 1,
1085 N_("Perform a number of minor, expensive optimizations") },
1086 {"thread-jumps", &flag_thread_jumps, 1,
1087 N_("Perform jump threading optimizations") },
1088 {"strength-reduce", &flag_strength_reduce, 1,
1089 N_("Perform strength reduction optimizations") },
1090 {"unroll-loops", &flag_unroll_loops, 1,
1091 N_("Perform loop unrolling when iteration count is known") },
1092 {"unroll-all-loops", &flag_unroll_all_loops, 1,
1093 N_("Perform loop unrolling for all loops") },
1094 {"old-unroll-loops", &flag_old_unroll_loops, 1,
1095 N_("Perform loop unrolling when iteration count is known") },
1096 {"old-unroll-all-loops", &flag_old_unroll_all_loops, 1,
1097 N_("Perform loop unrolling for all loops") },
1098 {"peel-loops", &flag_peel_loops, 1,
1099 N_("Perform loop peeling") },
1100 {"unswitch-loops", &flag_unswitch_loops, 1,
1101 N_("Perform loop unswitching") },
1102 {"prefetch-loop-arrays", &flag_prefetch_loop_arrays, 1,
1103 N_("Generate prefetch instructions, if available, for arrays in loops") },
1104 {"move-all-movables", &flag_move_all_movables, 1,
1105 N_("Force all loop invariant computations out of loops") },
1106 {"reduce-all-givs", &flag_reduce_all_givs, 1,
1107 N_("Strength reduce all loop general induction variables") },
1108 {"writable-strings", &flag_writable_strings, 1,
1109 N_("Store strings in writable data section") },
1110 {"peephole", &flag_no_peephole, 0,
1111 N_("Enable machine specific peephole optimizations") },
1112 {"force-mem", &flag_force_mem, 1,
1113 N_("Copy memory operands into registers before using") },
1114 {"force-addr", &flag_force_addr, 1,
1115 N_("Copy memory address constants into regs before using") },
1116 {"function-cse", &flag_no_function_cse, 0,
1117 N_("Allow function addresses to be held in registers") },
1118 {"inline-functions", &flag_inline_functions, 1,
1119 N_("Integrate simple functions into their callers") },
1120 {"keep-inline-functions", &flag_keep_inline_functions, 1,
1121 N_("Generate code for funcs even if they are fully inlined") },
1122 {"inline", &flag_no_inline, 0,
1123 N_("Pay attention to the 'inline' keyword") },
1124 {"keep-static-consts", &flag_keep_static_consts, 1,
1125 N_("Emit static const variables even if they are not used") },
1126 {"syntax-only", &flag_syntax_only, 1,
1127 N_("Check for syntax errors, then stop") },
1128 {"shared-data", &flag_shared_data, 1,
1129 N_("Mark data as shared rather than private") },
1130 {"caller-saves", &flag_caller_saves, 1,
1131 N_("Enable saving registers around function calls") },
1132 {"pcc-struct-return", &flag_pcc_struct_return, 1,
1133 N_("Return 'short' aggregates in memory, not registers") },
1134 {"reg-struct-return", &flag_pcc_struct_return, 0,
1135 N_("Return 'short' aggregates in registers") },
1136 {"delayed-branch", &flag_delayed_branch, 1,
1137 N_("Attempt to fill delay slots of branch instructions") },
1138 {"gcse", &flag_gcse, 1,
1139 N_("Perform the global common subexpression elimination") },
1140 {"gcse-lm", &flag_gcse_lm, 1,
1141 N_("Perform enhanced load motion during global subexpression elimination") },
1142 {"gcse-sm", &flag_gcse_sm, 1,
1143 N_("Perform store motion after global subexpression elimination") },
1144 {"branch-target-load-optimize", &flag_branch_target_load_optimize, 1,
1145 N_("Perform branch target load optimization before prologue / epilogue threading") },
1146 {"branch-target-load-optimize2", &flag_branch_target_load_optimize2, 1,
1147 N_("Perform branch target load optimization after prologue / epilogue threading") },
1148 {"loop-optimize", &flag_loop_optimize, 1,
1149 N_("Perform the loop optimizations") },
1150 {"crossjumping", &flag_crossjumping, 1,
1151 N_("Perform cross-jumping optimization") },
1152 {"if-conversion", &flag_if_conversion, 1,
1153 N_("Perform conversion of conditional jumps to branchless equivalents") },
1154 {"if-conversion2", &flag_if_conversion2, 1,
1155 N_("Perform conversion of conditional jumps to conditional execution") },
1156 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1,
1157 N_("Run CSE pass after loop optimizations") },
1158 {"rerun-loop-opt", &flag_rerun_loop_opt, 1,
1159 N_("Run the loop optimizer twice") },
1160 {"delete-null-pointer-checks", &flag_delete_null_pointer_checks, 1,
1161 N_("Delete useless null pointer checks") },
1162 {"schedule-insns", &flag_schedule_insns, 1,
1163 N_("Reschedule instructions before register allocation") },
1164 {"schedule-insns2", &flag_schedule_insns_after_reload, 1,
1165 N_("Reschedule instructions after register allocation") },
1166 {"sched-interblock",&flag_schedule_interblock, 1,
1167 N_("Enable scheduling across basic blocks") },
1168 {"sched-spec",&flag_schedule_speculative, 1,
1169 N_("Allow speculative motion of non-loads") },
1170 {"sched-spec-load",&flag_schedule_speculative_load, 1,
1171 N_("Allow speculative motion of some loads") },
1172 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1,
1173 N_("Allow speculative motion of more loads") },
1174 {"sched2-use-superblocks", &flag_sched2_use_superblocks, 1,
1175 N_("If scheduling post reload, do superblock scheduling") },
1176 {"sched2-use-traces", &flag_sched2_use_traces, 1,
1177 N_("If scheduling post reload, do trace scheduling") },
1178 {"branch-count-reg",&flag_branch_on_count_reg, 1,
1179 N_("Replace add,compare,branch with branch on count reg") },
1180 {"pic", &flag_pic, 1,
1181 N_("Generate position independent code, if possible") },
1182 {"PIC", &flag_pic, 2, ""},
1183 {"pie", &flag_pie, 1,
1184 N_("Generate position independent code for executables, if possible") },
1185 {"PIE", &flag_pie, 2, ""},
1186 {"exceptions", &flag_exceptions, 1,
1187 N_("Enable exception handling") },
1188 {"unwind-tables", &flag_unwind_tables, 1,
1189 N_("Just generate unwind tables for exception handling") },
1190 {"asynchronous-unwind-tables", &flag_asynchronous_unwind_tables, 1,
1191 N_("Generate unwind tables exact at each instruction boundary") },
1192 {"non-call-exceptions", &flag_non_call_exceptions, 1,
1193 N_("Support synchronous non-call exceptions") },
1194 {"profile-arcs", &profile_arc_flag, 1,
1195 N_("Insert arc based program profiling code") },
1196 {"test-coverage", &flag_test_coverage, 1,
1197 N_("Create data files needed by gcov") },
1198 {"branch-probabilities", &flag_branch_probabilities, 1,
1199 N_("Use profiling information for branch probabilities") },
1200 {"profile", &profile_flag, 1,
1201 N_("Enable basic program profiling code") },
1202 {"reorder-blocks", &flag_reorder_blocks, 1,
1203 N_("Reorder basic blocks to improve code placement") },
1204 {"reorder-functions", &flag_reorder_functions, 1,
1205 N_("Reorder functions to improve code placement") },
1206 {"rename-registers", &flag_rename_registers, 1,
1207 N_("Do the register renaming optimization pass") },
1208 {"cprop-registers", &flag_cprop_registers, 1,
1209 N_("Do the register copy-propagation optimization pass") },
1210 {"common", &flag_no_common, 0,
1211 N_("Do not put uninitialized globals in the common section") },
1212 {"inhibit-size-directive", &flag_inhibit_size_directive, 1,
1213 N_("Do not generate .size directives") },
1214 {"function-sections", &flag_function_sections, 1,
1215 N_("place each function into its own section") },
1216 {"data-sections", &flag_data_sections, 1,
1217 N_("place data items into their own section") },
1218 {"verbose-asm", &flag_verbose_asm, 1,
1219 N_("Add extra commentary to assembler output") },
1220 {"gnu-linker", &flag_gnu_linker, 1,
1221 N_("Output GNU ld formatted global initializers") },
1222 {"regmove", &flag_regmove, 1,
1223 N_("Enables a register move optimization") },
1224 {"optimize-register-move", &flag_regmove, 1,
1225 N_("Do the full regmove optimization pass") },
1226 {"pack-struct", &flag_pack_struct, 1,
1227 N_("Pack structure members together without holes") },
1228 {"stack-check", &flag_stack_check, 1,
1229 N_("Insert stack checking code into the program") },
1230 {"argument-alias", &flag_argument_noalias, 0,
1231 N_("Specify that arguments may alias each other & globals") },
1232 {"argument-noalias", &flag_argument_noalias, 1,
1233 N_("Assume arguments may alias globals but not each other") },
1234 {"argument-noalias-global", &flag_argument_noalias, 2,
1235 N_("Assume arguments do not alias each other or globals") },
1236 {"strict-aliasing", &flag_strict_aliasing, 1,
1237 N_("Assume strict aliasing rules apply") },
1238 {"align-loops", &align_loops, 0,
1239 N_("Align the start of loops") },
1240 {"align-jumps", &align_jumps, 0,
1241 N_("Align labels which are only reached by jumping") },
1242 {"align-labels", &align_labels, 0,
1243 N_("Align all labels") },
1244 {"align-functions", &align_functions, 0,
1245 N_("Align the start of functions") },
1246 {"merge-constants", &flag_merge_constants, 1,
1247 N_("Attempt to merge identical constants across compilation units") },
1248 {"merge-all-constants", &flag_merge_constants, 2,
1249 N_("Attempt to merge identical constants and constant variables") },
1250 {"dump-unnumbered", &flag_dump_unnumbered, 1,
1251 N_("Suppress output of instruction numbers and line number notes in debugging dumps") },
1252 {"instrument-functions", &flag_instrument_function_entry_exit, 1,
1253 N_("Instrument function entry/exit with profiling calls") },
1254 {"zero-initialized-in-bss", &flag_zero_initialized_in_bss, 1,
1255 N_("Put zero initialized data in the bss section") },
1256 {"ssa", &flag_ssa, 1,
1257 N_("Enable SSA optimizations") },
1258 {"ssa-ccp", &flag_ssa_ccp, 1,
1259 N_("Enable SSA conditional constant propagation") },
1260 {"ssa-dce", &flag_ssa_dce, 1,
1261 N_("Enable aggressive SSA dead code elimination") },
1262 {"leading-underscore", &flag_leading_underscore, 1,
1263 N_("External symbols have a leading underscore") },
1264 {"ident", &flag_no_ident, 0,
1265 N_("Process #ident directives") },
1266 { "peephole2", &flag_peephole2, 1,
1267 N_("Enables an rtl peephole pass run before sched2") },
1268 {"finite-math-only", &flag_finite_math_only, 1,
1269 N_("Assume no NaNs or +-Infs are generated") },
1270 { "guess-branch-probability", &flag_guess_branch_prob, 1,
1271 N_("Enables guessing of branch probabilities") },
1272 {"math-errno", &flag_errno_math, 1,
1273 N_("Set errno after built-in math functions") },
1274 {"trapping-math", &flag_trapping_math, 1,
1275 N_("Floating-point operations can trap") },
1276 {"unsafe-math-optimizations", &flag_unsafe_math_optimizations, 1,
1277 N_("Allow math optimizations that may violate IEEE or ANSI standards") },
1278 {"signaling-nans", &flag_signaling_nans, 1,
1279 N_("Disable optimizations observable by IEEE signaling NaNs") },
1280 {"bounds-check", &flag_bounds_check, 1,
1281 N_("Generate code to check bounds before indexing arrays") },
1282 {"single-precision-constant", &flag_single_precision_constant, 1,
1283 N_("Convert floating point constant to single precision constant") },
1284 {"time-report", &time_report, 1,
1285 N_("Report time taken by each compiler pass at end of run") },
1286 {"mem-report", &mem_report, 1,
1287 N_("Report on permanent memory allocation at end of run") },
1288 { "trapv", &flag_trapv, 1,
1289 N_("Trap for signed overflow in addition / subtraction / multiplication") },
1290 { "wrapv", &flag_wrapv, 1,
1291 N_("Assume signed arithmetic overflow wraps around") },
1292 { "new-ra", &flag_new_regalloc, 1,
1293 N_("Use graph coloring register allocation.") },
1296 /* Table of language-specific options. */
1298 static const struct lang_opt
1300 const char *const option;
1301 const char *const description;
1303 documented_lang_options[] =
1305 /* In order not to overload the --help output, the convention
1306 used here is to only describe those options which are not
1307 enabled by default. */
1310 N_("Compile just for ISO C90") },
1312 N_("Determine language standard") },
1314 { "-fsigned-bitfields", "" },
1315 { "-funsigned-bitfields",
1316 N_("Make bit-fields by unsigned by default") },
1317 { "-fno-signed-bitfields", "" },
1318 { "-fno-unsigned-bitfields","" },
1320 N_("Make 'char' be signed by default") },
1321 { "-funsigned-char",
1322 N_("Make 'char' be unsigned by default") },
1323 { "-fno-signed-char", "" },
1324 { "-fno-unsigned-char", "" },
1328 N_("Do not recognize the 'asm' keyword") },
1329 { "-fbuiltin", "" },
1331 N_("Do not recognize any built in functions") },
1333 N_("Assume normal C execution environment") },
1334 { "-fno-hosted", "" },
1336 N_("Assume that standard libraries & main might not exist") },
1337 { "-fno-freestanding", "" },
1338 { "-fcond-mismatch",
1339 N_("Allow different types as args of ? operator") },
1340 { "-fno-cond-mismatch", "" },
1341 { "-fdollars-in-identifiers",
1342 N_("Allow the use of $ inside identifiers") },
1343 { "-fno-dollars-in-identifiers", "" },
1344 { "-fpreprocessed", "" },
1345 { "-fno-preprocessed", "" },
1347 N_("Use the same size for double as for float") },
1348 { "-fno-short-double", "" },
1350 N_("Use the smallest fitting integer to hold enums") },
1351 { "-fno-short-enums", "" },
1353 N_("Override the underlying type for wchar_t to `unsigned short'") },
1354 { "-fno-short-wchar", "" },
1357 N_("Enable most warning messages") },
1358 { "-Wbad-function-cast",
1359 N_("Warn about casting functions to incompatible types") },
1360 { "-Wno-bad-function-cast", "" },
1361 { "-Wmissing-format-attribute",
1362 N_("Warn about functions which might be candidates for format attributes") },
1363 { "-Wno-missing-format-attribute", "" },
1365 N_("Warn about casts which discard qualifiers") },
1366 { "-Wno-cast-qual", "" },
1367 { "-Wchar-subscripts",
1368 N_("Warn about subscripts whose type is 'char'") },
1369 { "-Wno-char-subscripts", "" },
1371 N_("Warn if nested comments are detected") },
1372 { "-Wno-comment", "" },
1374 N_("Warn if nested comments are detected") },
1375 { "-Wno-comments", "" },
1377 N_("Warn about possibly confusing type conversions") },
1378 { "-Wno-conversion", "" },
1379 { "-Wdiv-by-zero", "" },
1380 { "-Wno-div-by-zero",
1381 N_("Do not warn about compile-time integer division by zero") },
1383 N_("Warn about testing equality of floating point numbers") },
1384 { "-Wno-float-equal", "" },
1386 N_("Warn about printf/scanf/strftime/strfmon format anomalies") },
1387 { "-Wno-format", "" },
1388 { "-Wformat-extra-args", "" },
1389 { "-Wno-format-extra-args",
1390 N_("Don't warn about too many arguments to format functions") },
1391 { "-Wformat-nonliteral",
1392 N_("Warn about non-string-literal format strings") },
1393 { "-Wno-format-nonliteral", "" },
1394 { "-Wformat-security",
1395 N_("Warn about possible security problems with format functions") },
1396 { "-Wno-format-security", "" },
1397 { "-Wformat-y2k", "" },
1398 { "-Wno-format-y2k",
1399 N_("Don't warn about strftime formats yielding 2 digit years") },
1400 { "-Wimplicit-function-declaration",
1401 N_("Warn about implicit function declarations") },
1402 { "-Wno-implicit-function-declaration", "" },
1403 { "-Werror-implicit-function-declaration", "" },
1405 N_("Warn when a declaration does not specify a type") },
1406 { "-Wno-implicit-int", "" },
1407 { "-Wimplicit", "" },
1408 { "-Wno-implicit", "" },
1410 N_("Warn about the use of the #import directive") },
1411 { "-Wno-import", "" },
1413 N_("Warn about PCH files that are found but not used") },
1414 { "-Wlong-long","" },
1416 N_("Do not warn about using 'long long' when -pedantic") },
1418 N_("Warn about suspicious declarations of main") },
1419 { "-Wno-main", "" },
1420 { "-Wmissing-braces",
1421 N_("Warn about possibly missing braces around initializers") },
1422 { "-Wno-missing-braces", "" },
1423 { "-Wmissing-declarations",
1424 N_("Warn about global funcs without previous declarations") },
1425 { "-Wno-missing-declarations", "" },
1426 { "-Wmissing-prototypes",
1427 N_("Warn about global funcs without prototypes") },
1428 { "-Wno-missing-prototypes", "" },
1430 N_("Warn about use of multicharacter literals") },
1431 { "-Wno-multichar", "" },
1432 { "-Wnested-externs",
1433 N_("Warn about externs not at file scope level") },
1434 { "-Wno-nested-externs", "" },
1436 N_("Warn about possible missing parentheses") },
1437 { "-Wno-parentheses", "" },
1438 { "-Wpointer-arith",
1439 N_("Warn about function pointer arithmetic") },
1440 { "-Wno-pointer-arith", "" },
1441 { "-Wredundant-decls",
1442 N_("Warn about multiple declarations of the same object") },
1443 { "-Wno-redundant-decls", "" },
1445 N_("Warn whenever a function's return-type defaults to int") },
1446 { "-Wno-return-type", "" },
1447 { "-Wsequence-point",
1448 N_("Warn about possible violations of sequence point rules") },
1449 { "-Wno-sequence-point", "" },
1451 N_("Warn about signed/unsigned comparisons") },
1452 { "-Wno-sign-compare", "" },
1453 { "-Wstrict-prototypes",
1454 N_("Warn about non-prototyped function decls") },
1455 { "-Wno-strict-prototypes", "" },
1457 N_("Warn about constructs whose meanings change in ISO C") },
1458 { "-Wno-traditional", "" },
1460 N_("Warn when trigraphs are encountered") },
1461 { "-Wno-trigraphs", "" },
1463 { "-Wno-undef", "" },
1464 { "-Wunknown-pragmas",
1465 N_("Warn about unrecognized pragmas") },
1466 { "-Wno-unknown-pragmas", "" },
1467 { "-Wwrite-strings",
1468 N_("Mark strings as 'const char *'") },
1469 { "-Wno-write-strings", "" },
1471 #define DEFINE_LANG_NAME(NAME) { NULL, NAME },
1473 #include "options_.h"
1477 /* Here is a table, controlled by the tm.h file, listing each -m switch
1478 and which bits in `target_switches' it should set or clear.
1479 If VALUE is positive, it is bits to set.
1480 If VALUE is negative, -VALUE is bits to clear.
1481 (The sign bit is not used so there is no confusion.) */
1485 const char *const name;
1487 const char *const description;
1489 target_switches[] = TARGET_SWITCHES;
1491 /* This table is similar, but allows the switch to have a value. */
1493 #ifdef TARGET_OPTIONS
1496 const char *const prefix;
1497 const char **const variable;
1498 const char *const description;
1499 const char *const value;
1501 target_options[] = TARGET_OPTIONS;
1504 /* Options controlling warnings. */
1506 /* Nonzero means warn about function definitions that default the return type
1507 or that use a null return and have a return-type other than void. */
1509 int warn_return_type;
1511 /* Used for the -W options array temporarily. */
1512 static int warn_dummy;
1514 /* Like f_options, but for -W. */
1516 static const lang_independent_options W_options[] =
1518 {"unused-function", &warn_dummy, 1,
1519 N_("Warn when a function is unused") },
1520 {"unused-label", &warn_dummy, 1,
1521 N_("Warn when a label is unused") },
1522 {"unused-parameter", &warn_dummy, 1,
1523 N_("Warn when a function parameter is unused") },
1524 {"unused-variable", &warn_dummy, 1,
1525 N_("Warn when a variable is unused") },
1526 {"unused-value", &warn_dummy, 1,
1527 N_("Warn when an expression value is unused") },
1528 {"system-headers", &warn_dummy, 1,
1529 N_("Do not suppress warnings from system headers") },
1530 {"error", &warn_dummy, 1,
1531 N_("Treat all warnings as errors") },
1532 {"shadow", &warn_dummy, 1,
1533 N_("Warn when one local variable shadows another") },
1534 {"switch", &warn_dummy, 1,
1535 N_("Warn about enumerated switches, with no default, missing a case") },
1536 {"switch-default", &warn_dummy, 1,
1537 N_("Warn about enumerated switches missing a default case") },
1538 {"switch-enum", &warn_dummy, 1,
1539 N_("Warn about all enumerated switches missing a specific case") },
1540 {"aggregate-return", &warn_dummy, 1,
1541 N_("Warn about returning structures, unions or arrays") },
1542 {"cast-align", &warn_dummy, 1,
1543 N_("Warn about pointer casts which increase alignment") },
1544 {"unreachable-code", &warn_dummy, 1,
1545 N_("Warn about code that will never be executed") },
1546 {"uninitialized", &warn_dummy, 1,
1547 N_("Warn about uninitialized automatic variables") },
1548 {"inline", &warn_dummy, 1,
1549 N_("Warn when an inlined function cannot be inlined") },
1550 {"packed", &warn_dummy, 1,
1551 N_("Warn when the packed attribute has no effect on struct layout") },
1552 {"padded", &warn_dummy, 1,
1553 N_("Warn when padding is required to align struct members") },
1554 {"disabled-optimization", &warn_dummy, 1,
1555 N_("Warn when an optimization pass is disabled") },
1556 {"deprecated-declarations", &warn_dummy, 1,
1557 N_("Warn about uses of __attribute__((deprecated)) declarations") },
1558 {"missing-noreturn", &warn_dummy, 1,
1559 N_("Warn about functions which might be candidates for attribute noreturn") },
1560 {"strict-aliasing", &warn_dummy, 1,
1561 N_ ("Warn about code which might break the strict aliasing rules") }
1564 /* Output files for assembler code (real compiler output)
1565 and debugging dumps. */
1568 FILE *aux_info_file;
1569 FILE *rtl_dump_file = NULL;
1571 /* Set up a default flag_random_seed and local_tick, unless the user
1572 already specified one. */
1577 if (!flag_random_seed)
1579 unsigned HOST_WIDE_INT value;
1580 static char random_seed[HOST_BITS_PER_WIDE_INT / 4 + 3];
1582 /* Get some more or less random data. */
1583 #ifdef HAVE_GETTIMEOFDAY
1587 gettimeofday (&tv, NULL);
1588 local_tick = tv.tv_sec * 1000 + tv.tv_usec / 1000;
1592 time_t now = time ();
1594 if (now != (time_t)-1)
1595 local_tick = (unsigned) now;
1598 value = local_tick ^ getpid ();
1600 sprintf (random_seed, HOST_WIDE_INT_PRINT_HEX, value);
1601 flag_random_seed = random_seed;
1608 /* Decode the string P as an integral parameter.
1609 If the string is indeed an integer return its numeric value else
1610 issue an Invalid Option error for the option PNAME and return DEFVAL.
1611 If PNAME is zero just return DEFVAL, do not call error. */
1614 read_integral_parameter (const char *p, const char *pname, const int defval)
1616 const char *endp = p;
1620 if (ISDIGIT (*endp))
1629 error ("invalid option argument `%s'", pname);
1636 /* Return the logarithm of X, base 2, considering X unsigned,
1637 if X is a power of 2. Otherwise, returns -1.
1639 This should be used via the `exact_log2' macro. */
1642 exact_log2_wide (unsigned HOST_WIDE_INT x)
1645 /* Test for 0 or a power of 2. */
1646 if (x == 0 || x != (x & -x))
1648 while ((x >>= 1) != 0)
1653 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1654 If X is 0, return -1.
1656 This should be used via the floor_log2 macro. */
1659 floor_log2_wide (unsigned HOST_WIDE_INT x)
1668 /* Handler for fatal signals, such as SIGSEGV. These are transformed
1669 into ICE messages, which is much more user friendly. In case the
1670 error printer crashes, reset the signal to prevent infinite recursion. */
1673 crash_signal (int signo)
1675 signal (signo, SIG_DFL);
1676 internal_error ("%s", strsignal (signo));
1679 /* Arrange to dump core on error. (The regular error message is still
1680 printed first, except in the case of abort().) */
1683 setup_core_dumping (void)
1686 signal (SIGABRT, SIG_DFL);
1688 #if defined(HAVE_SETRLIMIT)
1691 if (getrlimit (RLIMIT_CORE, &rlim) != 0)
1692 fatal_error ("getting core file size maximum limit: %m");
1693 rlim.rlim_cur = rlim.rlim_max;
1694 if (setrlimit (RLIMIT_CORE, &rlim) != 0)
1695 fatal_error ("setting core file size limit to maximum: %m");
1698 diagnostic_abort_on_error (global_dc);
1702 /* Strip off a legitimate source ending from the input string NAME of
1703 length LEN. Rather than having to know the names used by all of
1704 our front ends, we strip off an ending of a period followed by
1705 up to five characters. (Java uses ".class".) */
1708 strip_off_ending (char *name, int len)
1711 for (i = 2; i < 6 && len > i; i++)
1713 if (name[len - i] == '.')
1715 name[len - i] = '\0';
1721 /* Output a quoted string. */
1724 output_quoted_string (FILE *asm_file, const char *string)
1726 #ifdef OUTPUT_QUOTED_STRING
1727 OUTPUT_QUOTED_STRING (asm_file, string);
1731 putc ('\"', asm_file);
1732 while ((c = *string++) != 0)
1736 if (c == '\"' || c == '\\')
1737 putc ('\\', asm_file);
1741 fprintf (asm_file, "\\%03o", (unsigned char) c);
1743 putc ('\"', asm_file);
1747 /* Output a file name in the form wanted by System V. */
1750 output_file_directive (FILE *asm_file, const char *input_name)
1752 int len = strlen (input_name);
1753 const char *na = input_name + len;
1755 /* NA gets INPUT_NAME sans directory names. */
1756 while (na > input_name)
1758 if (IS_DIR_SEPARATOR (na[-1]))
1763 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1764 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
1766 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1767 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1769 fprintf (asm_file, "\t.file\t");
1770 output_quoted_string (asm_file, na);
1771 fputc ('\n', asm_file);
1776 /* Routine to open a dump file. Return true if the dump file is enabled. */
1779 open_dump_file (enum dump_file_index index, tree decl)
1782 const char *open_arg;
1785 if (! dump_file[index].enabled)
1788 timevar_push (TV_DUMP);
1789 if (rtl_dump_file != NULL)
1790 fclose (rtl_dump_file);
1792 sprintf (seq, DUMPFILE_FORMAT, index);
1794 if (! dump_file[index].initialized)
1796 /* If we've not initialized the files, do so now. */
1797 if (graph_dump_format != no_graph
1798 && dump_file[index].graph_dump_p)
1800 dump_name = concat (seq, dump_file[index].extension, NULL);
1801 clean_graph_dump_file (dump_base_name, dump_name);
1804 dump_file[index].initialized = 1;
1810 dump_name = concat (dump_base_name, seq,
1811 dump_file[index].extension, NULL);
1813 rtl_dump_file = fopen (dump_name, open_arg);
1814 if (rtl_dump_file == NULL)
1815 fatal_error ("can't open %s: %m", dump_name);
1820 fprintf (rtl_dump_file, "\n;; Function %s%s\n\n",
1821 (*lang_hooks.decl_printable_name) (decl, 2),
1822 cfun->function_frequency == FUNCTION_FREQUENCY_HOT
1824 : cfun->function_frequency == FUNCTION_FREQUENCY_UNLIKELY_EXECUTED
1825 ? " (unlikely executed)"
1828 timevar_pop (TV_DUMP);
1832 /* Routine to close a dump file. */
1835 close_dump_file (enum dump_file_index index,
1836 void (*func) (FILE *, rtx),
1839 if (! rtl_dump_file)
1842 timevar_push (TV_DUMP);
1844 && graph_dump_format != no_graph
1845 && dump_file[index].graph_dump_p)
1850 sprintf (seq, DUMPFILE_FORMAT, index);
1851 suffix = concat (seq, dump_file[index].extension, NULL);
1852 print_rtl_graph_with_bb (dump_base_name, suffix, insns);
1857 func (rtl_dump_file, insns);
1859 fflush (rtl_dump_file);
1860 fclose (rtl_dump_file);
1862 rtl_dump_file = NULL;
1863 timevar_pop (TV_DUMP);
1866 /* Do any final processing required for the declarations in VEC, of
1867 which there are LEN. We write out inline functions and variables
1868 that have been deferred until this point, but which are required.
1869 Returns nonzero if anything was put out. */
1872 wrapup_global_declarations (tree *vec, int len)
1877 int output_something = 0;
1879 for (i = 0; i < len; i++)
1883 /* We're not deferring this any longer. Assignment is
1884 conditional to avoid needlessly dirtying PCH pages. */
1885 if (DECL_DEFER_OUTPUT (decl) != 0)
1886 DECL_DEFER_OUTPUT (decl) = 0;
1888 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0)
1889 (*lang_hooks.finish_incomplete_decl) (decl);
1892 /* Now emit any global variables or functions that we have been
1893 putting off. We need to loop in case one of the things emitted
1894 here references another one which comes earlier in the list. */
1898 for (i = 0; i < len; i++)
1902 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
1905 /* Don't write out static consts, unless we still need them.
1907 We also keep static consts if not optimizing (for debugging),
1908 unless the user specified -fno-keep-static-consts.
1909 ??? They might be better written into the debug information.
1910 This is possible when using DWARF.
1912 A language processor that wants static constants to be always
1913 written out (even if it is not used) is responsible for
1914 calling rest_of_decl_compilation itself. E.g. the C front-end
1915 calls rest_of_decl_compilation from finish_decl.
1916 One motivation for this is that is conventional in some
1917 environments to write things like:
1918 static const char rcsid[] = "... version string ...";
1919 intending to force the string to be in the executable.
1921 A language processor that would prefer to have unneeded
1922 static constants "optimized away" would just defer writing
1923 them out until here. E.g. C++ does this, because static
1924 constants are often defined in header files.
1926 ??? A tempting alternative (for both C and C++) would be
1927 to force a constant to be written if and only if it is
1928 defined in a main file, as opposed to an include file. */
1930 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl))
1934 if (flag_unit_at_a_time
1935 && cgraph_varpool_node (decl)->finalized)
1937 else if (flag_unit_at_a_time
1938 && (TREE_USED (decl)
1939 || TREE_USED (DECL_ASSEMBLER_NAME (decl))))
1941 else if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
1943 else if (DECL_COMDAT (decl))
1945 else if (TREE_READONLY (decl) && !TREE_PUBLIC (decl)
1946 && (optimize || !flag_keep_static_consts
1947 || DECL_ARTIFICIAL (decl)))
1953 rest_of_decl_compilation (decl, NULL, 1, 1);
1957 if (TREE_CODE (decl) == FUNCTION_DECL
1958 && DECL_INITIAL (decl) != 0
1959 && DECL_SAVED_INSNS (decl) != 0
1960 && (flag_keep_inline_functions
1961 || (TREE_PUBLIC (decl) && !DECL_COMDAT (decl))
1962 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
1965 output_inline_function (decl);
1970 output_something = 1;
1974 return output_something;
1977 /* Issue appropriate warnings for the global declarations in VEC (of
1978 which there are LEN). Output debugging information for them. */
1981 check_global_declarations (tree *vec, int len)
1986 for (i = 0; i < len; i++)
1990 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
1991 && ! TREE_ASM_WRITTEN (decl))
1992 /* Cancel the RTL for this decl so that, if debugging info
1993 output for global variables is still to come,
1994 this one will be omitted. */
1995 SET_DECL_RTL (decl, NULL_RTX);
1997 /* Warn about any function
1998 declared static but not defined.
1999 We don't warn about variables,
2000 because many programs have static variables
2001 that exist only to get some text into the object file. */
2002 if (TREE_CODE (decl) == FUNCTION_DECL
2003 && (warn_unused_function
2004 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2005 && DECL_INITIAL (decl) == 0
2006 && DECL_EXTERNAL (decl)
2007 && ! DECL_ARTIFICIAL (decl)
2008 && ! TREE_PUBLIC (decl))
2010 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
2011 pedwarn_with_decl (decl,
2012 "`%s' used but never defined");
2014 warning_with_decl (decl,
2015 "`%s' declared `static' but never defined");
2016 /* This symbol is effectively an "extern" declaration now. */
2017 TREE_PUBLIC (decl) = 1;
2018 assemble_external (decl);
2021 /* Warn about static fns or vars defined but not used. */
2022 if (((warn_unused_function && TREE_CODE (decl) == FUNCTION_DECL)
2023 || (warn_unused_variable && TREE_CODE (decl) == VAR_DECL))
2024 && ! TREE_USED (decl)
2025 /* The TREE_USED bit for file-scope decls is kept in the identifier,
2026 to handle multiple external decls in different scopes. */
2027 && ! TREE_USED (DECL_NAME (decl))
2028 && ! DECL_EXTERNAL (decl)
2029 && ! TREE_PUBLIC (decl)
2030 /* A volatile variable might be used in some non-obvious way. */
2031 && ! TREE_THIS_VOLATILE (decl)
2032 /* Global register variables must be declared to reserve them. */
2033 && ! (TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl))
2034 /* Otherwise, ask the language. */
2035 && (*lang_hooks.decls.warn_unused_global) (decl))
2036 warning_with_decl (decl, "`%s' defined but not used");
2038 /* Avoid confusing the debug information machinery when there are
2040 if (errorcount == 0 && sorrycount == 0)
2042 timevar_push (TV_SYMOUT);
2043 (*debug_hooks->global_decl) (decl);
2044 timevar_pop (TV_SYMOUT);
2049 /* Save the current INPUT_LOCATION on the top entry in the
2050 INPUT_FILE_STACK. Push a new entry for FILE and LINE, and set the
2051 INPUT_LOCATION accordingly. */
2054 push_srcloc (const char *file, int line)
2056 struct file_stack *fs;
2058 fs = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2059 fs->location = input_location;
2060 fs->next = input_file_stack;
2061 input_filename = file;
2063 input_file_stack = fs;
2064 input_file_stack_tick++;
2067 /* Pop the top entry off the stack of presently open source files.
2068 Restore the INPUT_LOCATION from the new topmost entry on the
2074 struct file_stack *fs;
2076 fs = input_file_stack;
2077 input_location = fs->location;
2078 input_file_stack = fs->next;
2080 input_file_stack_tick++;
2083 /* Compile an entire translation unit. Write a file of assembly
2084 output and various debugging dumps. */
2089 /* Initialize yet another pass. */
2091 init_final (main_input_filename);
2092 coverage_init (aux_base_name);
2094 timevar_push (TV_PARSE);
2096 /* Call the parser, which parses the entire file (calling
2097 rest_of_compilation for each function). */
2098 (*lang_hooks.parse_file) (set_yydebug);
2100 /* In case there were missing block closers,
2101 get us back to the global binding level. */
2102 (*lang_hooks.clear_binding_stack) ();
2104 /* Compilation is now finished except for writing
2105 what's left of the symbol table output. */
2106 timevar_pop (TV_PARSE);
2108 if (flag_syntax_only)
2111 (*lang_hooks.decls.final_write_globals)();
2113 cgraph_varpool_assemble_pending_decls ();
2115 /* This must occur after the loop to output deferred functions.
2116 Else the coverage initializer would not be emitted if all the
2117 functions in this compilation unit were deferred. */
2120 /* Write out any pending weak symbol declarations. */
2124 /* Do dbx symbols. */
2125 timevar_push (TV_SYMOUT);
2127 #ifdef DWARF2_UNWIND_INFO
2128 if (dwarf2out_do_frame ())
2129 dwarf2out_frame_finish ();
2132 (*debug_hooks->finish) (main_input_filename);
2133 timevar_pop (TV_SYMOUT);
2135 /* Output some stuff at end of file if nec. */
2137 dw2_output_indirect_constants ();
2139 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
2141 timevar_push (TV_DUMP);
2142 open_dump_file (DFI_bp, NULL);
2146 close_dump_file (DFI_bp, NULL, NULL_RTX);
2147 timevar_pop (TV_DUMP);
2150 targetm.asm_out.file_end ();
2152 /* Attach a special .ident directive to the end of the file to identify
2153 the version of GCC which compiled this code. The format of the .ident
2154 string is patterned after the ones produced by native SVR4 compilers. */
2157 fprintf (asm_out_file, "%s\"GCC: (GNU) %s\"\n",
2158 IDENT_ASM_OP, version_string);
2161 if (optimize > 0 && open_dump_file (DFI_combine, NULL))
2163 timevar_push (TV_DUMP);
2164 dump_combine_total_stats (rtl_dump_file);
2165 close_dump_file (DFI_combine, NULL, NULL_RTX);
2166 timevar_pop (TV_DUMP);
2170 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
2171 and TYPE_DECL nodes.
2173 This does nothing for local (non-static) variables, unless the
2174 variable is a register variable with an ASMSPEC. In that case, or
2175 if the variable is not an automatic, it sets up the RTL and
2176 outputs any assembler code (label definition, storage allocation
2177 and initialization).
2179 DECL is the declaration. If ASMSPEC is nonzero, it specifies
2180 the assembler symbol name to be used. TOP_LEVEL is nonzero
2181 if this declaration is not within a function. */
2184 rest_of_decl_compilation (tree decl,
2185 const char *asmspec,
2189 /* We deferred calling assemble_alias so that we could collect
2190 other attributes such as visibility. Emit the alias now. */
2193 alias = lookup_attribute ("alias", DECL_ATTRIBUTES (decl));
2196 alias = TREE_VALUE (TREE_VALUE (alias));
2197 alias = get_identifier (TREE_STRING_POINTER (alias));
2198 assemble_alias (decl, alias);
2202 /* Forward declarations for nested functions are not "external",
2203 but we need to treat them as if they were. */
2204 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
2205 || TREE_CODE (decl) == FUNCTION_DECL)
2207 timevar_push (TV_VARCONST);
2210 make_decl_rtl (decl, asmspec);
2212 /* Don't output anything when a tentative file-scope definition
2213 is seen. But at end of compilation, do output code for them. */
2214 if (at_end || !DECL_DEFER_OUTPUT (decl))
2216 if (flag_unit_at_a_time && !cgraph_global_info_ready
2217 && TREE_CODE (decl) != FUNCTION_DECL && top_level)
2218 cgraph_varpool_finalize_decl (decl);
2220 assemble_variable (decl, top_level, at_end, 0);
2223 #ifdef ASM_FINISH_DECLARE_OBJECT
2224 if (decl == last_assemble_variable_decl)
2226 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
2231 timevar_pop (TV_VARCONST);
2233 else if (DECL_REGISTER (decl) && asmspec != 0)
2235 if (decode_reg_name (asmspec) >= 0)
2237 SET_DECL_RTL (decl, NULL_RTX);
2238 make_decl_rtl (decl, asmspec);
2242 error ("invalid register name `%s' for register variable", asmspec);
2243 DECL_REGISTER (decl) = 0;
2248 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2249 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2250 && TREE_CODE (decl) == TYPE_DECL)
2252 timevar_push (TV_SYMOUT);
2253 dbxout_symbol (decl, 0);
2254 timevar_pop (TV_SYMOUT);
2257 #ifdef SDB_DEBUGGING_INFO
2258 else if (write_symbols == SDB_DEBUG && top_level
2259 && TREE_CODE (decl) == TYPE_DECL)
2261 timevar_push (TV_SYMOUT);
2262 sdbout_symbol (decl, 0);
2263 timevar_pop (TV_SYMOUT);
2266 #ifdef DWARF2_DEBUGGING_INFO
2267 else if ((write_symbols == DWARF2_DEBUG
2268 || write_symbols == VMS_AND_DWARF2_DEBUG)
2270 && TREE_CODE (decl) == TYPE_DECL)
2272 timevar_push (TV_SYMOUT);
2273 dwarf2out_decl (decl);
2274 timevar_pop (TV_SYMOUT);
2279 /* Called after finishing a record, union or enumeral type. */
2282 rest_of_type_compilation (
2283 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) \
2284 || defined (SDB_DEBUGGING_INFO) || defined (DWARF2_DEBUGGING_INFO)
2288 tree type ATTRIBUTE_UNUSED,
2289 int toplev ATTRIBUTE_UNUSED
2293 /* Avoid confusing the debug information machinery when there are
2295 if (errorcount != 0 || sorrycount != 0)
2298 timevar_push (TV_SYMOUT);
2299 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2300 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2301 dbxout_symbol (TYPE_STUB_DECL (type), !toplev);
2303 #ifdef SDB_DEBUGGING_INFO
2304 if (write_symbols == SDB_DEBUG)
2305 sdbout_symbol (TYPE_STUB_DECL (type), !toplev);
2307 #ifdef DWARF2_DEBUGGING_INFO
2308 if ((write_symbols == DWARF2_DEBUG
2309 || write_symbols == VMS_AND_DWARF2_DEBUG)
2311 dwarf2out_decl (TYPE_STUB_DECL (type));
2313 timevar_pop (TV_SYMOUT);
2316 /* Turn the RTL into assembly. */
2318 rest_of_handle_final (tree decl, rtx insns)
2320 timevar_push (TV_FINAL);
2325 /* Get the function's name, as described by its RTL. This may be
2326 different from the DECL_NAME name used in the source file. */
2328 x = DECL_RTL (decl);
2329 if (GET_CODE (x) != MEM)
2332 if (GET_CODE (x) != SYMBOL_REF)
2334 fnname = XSTR (x, 0);
2336 assemble_start_function (decl, fnname);
2337 final_start_function (insns, asm_out_file, optimize);
2338 final (insns, asm_out_file, optimize, 0);
2339 final_end_function ();
2341 #ifdef IA64_UNWIND_INFO
2342 /* ??? The IA-64 ".handlerdata" directive must be issued before
2343 the ".endp" directive that closes the procedure descriptor. */
2344 output_function_exception_table ();
2347 assemble_end_function (decl, fnname);
2349 #ifndef IA64_UNWIND_INFO
2350 /* Otherwise, it feels unclean to switch sections in the middle. */
2351 output_function_exception_table ();
2355 fflush (asm_out_file);
2357 /* Release all memory allocated by flow. */
2358 free_basic_block_vars (0);
2360 /* Release all memory held by regsets now. */
2361 regset_release_memory ();
2363 timevar_pop (TV_FINAL);
2369 /* Run delay slot optimization. */
2371 rest_of_handle_delay_slots (tree decl, rtx insns)
2373 timevar_push (TV_DBR_SCHED);
2374 open_dump_file (DFI_dbr, decl);
2376 dbr_schedule (insns, rtl_dump_file);
2378 close_dump_file (DFI_dbr, print_rtl, insns);
2379 timevar_pop (TV_DBR_SCHED);
2386 /* Convert register usage from flat register file usage to a stack
2389 rest_of_handle_stack_regs (tree decl, rtx insns)
2391 timevar_push (TV_REG_STACK);
2392 open_dump_file (DFI_stack, decl);
2394 if (reg_to_stack (insns, rtl_dump_file) && optimize)
2396 if (cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK
2397 | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0))
2398 && flag_reorder_blocks)
2400 reorder_basic_blocks ();
2401 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK);
2405 close_dump_file (DFI_stack, print_rtl_with_bb, insns);
2406 timevar_pop (TV_REG_STACK);
2413 /* Machine independent reorg pass. */
2415 rest_of_handle_machine_reorg (tree decl, rtx insns)
2417 timevar_push (TV_MACH_DEP);
2418 open_dump_file (DFI_mach, decl);
2420 (*targetm.machine_dependent_reorg) ();
2422 close_dump_file (DFI_mach, print_rtl, insns);
2423 timevar_pop (TV_MACH_DEP);
2429 /* Run new register allocator. Return TRUE if we must exit
2430 rest_of_compilation upon return. */
2432 rest_of_handle_new_regalloc (tree decl, rtx insns, int *rebuild_notes)
2436 delete_trivially_dead_insns (insns, max_reg_num ());
2439 timevar_pop (TV_LOCAL_ALLOC);
2440 if (dump_file[DFI_lreg].enabled)
2442 timevar_push (TV_DUMP);
2444 close_dump_file (DFI_lreg, NULL, NULL);
2445 timevar_pop (TV_DUMP);
2448 /* XXX clean up the whole mess to bring live info in shape again. */
2449 timevar_push (TV_GLOBAL_ALLOC);
2450 open_dump_file (DFI_greg, decl);
2452 build_insn_chain (insns);
2453 failure = reload (insns, 0);
2455 timevar_pop (TV_GLOBAL_ALLOC);
2457 if (dump_file[DFI_greg].enabled)
2459 timevar_push (TV_DUMP);
2461 dump_global_regs (rtl_dump_file);
2463 close_dump_file (DFI_greg, print_rtl_with_bb, insns);
2464 timevar_pop (TV_DUMP);
2470 reload_completed = 1;
2476 /* Run old register allocator. Return TRUE if we must exit
2477 rest_of_compilation upon return. */
2479 rest_of_handle_old_regalloc (tree decl, rtx insns, int *rebuild_notes)
2483 /* Allocate the reg_renumber array. */
2484 allocate_reg_info (max_regno, FALSE, TRUE);
2486 /* And the reg_equiv_memory_loc array. */
2487 reg_equiv_memory_loc = (rtx *) xcalloc (max_regno, sizeof (rtx));
2489 allocate_initial_values (reg_equiv_memory_loc);
2491 regclass (insns, max_reg_num (), rtl_dump_file);
2492 *rebuild_notes = local_alloc ();
2494 timevar_pop (TV_LOCAL_ALLOC);
2496 if (dump_file[DFI_lreg].enabled)
2498 timevar_push (TV_DUMP);
2500 dump_flow_info (rtl_dump_file);
2501 dump_local_alloc (rtl_dump_file);
2503 close_dump_file (DFI_lreg, print_rtl_with_bb, insns);
2504 timevar_pop (TV_DUMP);
2509 timevar_push (TV_GLOBAL_ALLOC);
2510 open_dump_file (DFI_greg, decl);
2512 /* If optimizing, allocate remaining pseudo-regs. Do the reload
2513 pass fixing up any insns that are invalid. */
2516 failure = global_alloc (rtl_dump_file);
2519 build_insn_chain (insns);
2520 failure = reload (insns, 0);
2523 timevar_pop (TV_GLOBAL_ALLOC);
2525 if (dump_file[DFI_greg].enabled)
2527 timevar_push (TV_DUMP);
2529 dump_global_regs (rtl_dump_file);
2531 close_dump_file (DFI_greg, print_rtl_with_bb, insns);
2532 timevar_pop (TV_DUMP);
2538 /* Run the regrename and cprop passes. */
2540 rest_of_handle_regrename (tree decl, rtx insns)
2542 timevar_push (TV_RENAME_REGISTERS);
2543 open_dump_file (DFI_rnreg, decl);
2545 if (flag_rename_registers)
2546 regrename_optimize ();
2547 if (flag_cprop_registers)
2548 copyprop_hardreg_forward ();
2550 close_dump_file (DFI_rnreg, print_rtl_with_bb, insns);
2551 timevar_pop (TV_RENAME_REGISTERS);
2554 /* Reorder basic blocks. */
2556 rest_of_handle_reorder_blocks (tree decl, rtx insns)
2558 timevar_push (TV_REORDER_BLOCKS);
2559 open_dump_file (DFI_bbro, decl);
2561 /* Last attempt to optimize CFG, as scheduling, peepholing and insn
2562 splitting possibly introduced more crossjumping opportunities. */
2563 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE
2564 | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0));
2566 if (flag_sched2_use_traces && flag_schedule_insns_after_reload)
2568 if (flag_reorder_blocks)
2569 reorder_basic_blocks ();
2570 if (flag_reorder_blocks
2571 || (flag_sched2_use_traces && flag_schedule_insns_after_reload))
2572 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
2574 close_dump_file (DFI_bbro, print_rtl_with_bb, insns);
2575 timevar_pop (TV_REORDER_BLOCKS);
2578 #ifdef INSN_SCHEDULING
2579 /* Run instruction scheduler. */
2581 rest_of_handle_sched (tree decl, rtx insns)
2583 timevar_push (TV_SCHED);
2585 /* Print function header into sched dump now
2586 because doing the sched analysis makes some of the dump. */
2587 if (optimize > 0 && flag_schedule_insns)
2589 open_dump_file (DFI_sched, decl);
2591 /* Do control and data sched analysis,
2592 and write some of the results to dump file. */
2594 schedule_insns (rtl_dump_file);
2596 close_dump_file (DFI_sched, print_rtl_with_bb, insns);
2598 timevar_pop (TV_SCHED);
2603 /* Run second scheduling pass after reload. */
2605 rest_of_handle_sched2 (tree decl, rtx insns)
2607 timevar_push (TV_SCHED2);
2608 open_dump_file (DFI_sched2, decl);
2610 /* Do control and data sched analysis again,
2611 and write some more of the results to dump file. */
2613 split_all_insns (1);
2615 if (flag_sched2_use_superblocks || flag_sched2_use_traces)
2617 schedule_ebbs (rtl_dump_file);
2618 /* No liveness updating code yet, but it should be easy to do.
2619 reg-stack recompute the liveness when needed for now. */
2620 count_or_remove_death_notes (NULL, 1);
2621 cleanup_cfg (CLEANUP_EXPENSIVE);
2624 schedule_insns (rtl_dump_file);
2626 close_dump_file (DFI_sched2, print_rtl_with_bb, insns);
2627 timevar_pop (TV_SCHED2);
2633 /* Register allocation pre-pass, to reduce number of moves necessary
2634 for two-address machines. */
2636 rest_of_handle_regmove (tree decl, rtx insns)
2638 timevar_push (TV_REGMOVE);
2639 open_dump_file (DFI_regmove, decl);
2641 regmove_optimize (insns, max_reg_num (), rtl_dump_file);
2643 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
2644 close_dump_file (DFI_regmove, print_rtl_with_bb, insns);
2645 timevar_pop (TV_REGMOVE);
2652 rest_of_handle_tracer (tree decl, rtx insns)
2654 timevar_push (TV_TRACER);
2655 open_dump_file (DFI_tracer, decl);
2657 dump_flow_info (rtl_dump_file);
2659 cleanup_cfg (CLEANUP_EXPENSIVE);
2660 reg_scan (insns, max_reg_num (), 0);
2661 close_dump_file (DFI_tracer, print_rtl_with_bb, get_insns ());
2662 timevar_pop (TV_TRACER);
2665 /* If-conversion and CFG cleanup. */
2667 rest_of_handle_if_conversion (tree decl, rtx insns)
2669 open_dump_file (DFI_ce1, decl);
2670 if (flag_if_conversion)
2672 timevar_push (TV_IFCVT);
2674 dump_flow_info (rtl_dump_file);
2675 cleanup_cfg (CLEANUP_EXPENSIVE);
2676 reg_scan (insns, max_reg_num (), 0);
2678 timevar_pop (TV_IFCVT);
2680 timevar_push (TV_JUMP);
2681 cleanup_cfg (CLEANUP_EXPENSIVE);
2682 reg_scan (insns, max_reg_num (), 0);
2683 timevar_pop (TV_JUMP);
2684 close_dump_file (DFI_ce1, print_rtl_with_bb, get_insns ());
2687 /* Rerun if-conversion, as combine may have simplified things enough
2688 to now meet sequence length restrictions. */
2690 rest_of_handle_if_after_combine (tree decl, rtx insns)
2692 timevar_push (TV_IFCVT);
2693 open_dump_file (DFI_ce2, decl);
2699 close_dump_file (DFI_ce2, print_rtl_with_bb, insns);
2700 timevar_pop (TV_IFCVT);
2703 /* Do branch profiling and static profile estimation passes. */
2705 rest_of_handle_branch_prob (tree decl, rtx insns)
2709 timevar_push (TV_BRANCH_PROB);
2710 open_dump_file (DFI_bp, decl);
2711 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
2714 /* Discover and record the loop depth at the head of each basic
2715 block. The loop infrastructure does the real job for us. */
2716 flow_loops_find (&loops, LOOP_TREE);
2719 flow_loops_dump (&loops, rtl_dump_file, NULL, 0);
2721 /* Estimate using heuristics if no profiling info is available. */
2722 if (flag_guess_branch_prob)
2723 estimate_probability (&loops);
2725 flow_loops_free (&loops);
2726 close_dump_file (DFI_bp, print_rtl_with_bb, insns);
2727 timevar_pop (TV_BRANCH_PROB);
2730 /* Do control and data flow analysis; write some of the results to the
2733 rest_of_handle_cfg (tree decl, rtx insns)
2735 open_dump_file (DFI_cfg, decl);
2737 dump_flow_info (rtl_dump_file);
2739 cleanup_cfg (CLEANUP_EXPENSIVE
2740 | (flag_thread_jumps ? CLEANUP_THREADING : 0));
2742 /* It may make more sense to mark constant functions after dead code is
2743 eliminated by life_analysis, but we need to do it early, as -fprofile-arcs
2744 may insert code making function non-constant, but we still must consider
2745 it as constant, otherwise -fbranch-probabilities will not read data back.
2747 life_analysis rarely eliminates modification of external memory.
2750 mark_constant_function ();
2752 close_dump_file (DFI_cfg, print_rtl_with_bb, insns);
2755 /* Purge addressofs. */
2757 rest_of_handle_addresof (tree decl, rtx insns)
2759 open_dump_file (DFI_addressof, decl);
2761 purge_addressof (insns);
2763 purge_all_dead_edges (0);
2764 reg_scan (insns, max_reg_num (), 1);
2766 close_dump_file (DFI_addressof, print_rtl, insns);
2769 /* We may have potential sibling or tail recursion sites. Select one
2770 (of possibly multiple) methods of performing the call. */
2772 rest_of_handle_sibling_calls (rtx insns)
2775 optimize_sibling_and_tail_recursive_calls ();
2777 /* Recompute the CFG as sibling optimization clobbers it randomly. */
2778 free_bb_for_insn ();
2779 find_exception_handler_labels ();
2780 rebuild_jump_labels (insns);
2781 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2783 /* There is pass ordering problem - we must lower NOTE_INSN_PREDICTION
2784 notes before simplifying cfg and we must do lowering after sibcall
2785 that unhides parts of RTL chain and cleans up the CFG.
2787 Until sibcall is replaced by tree-level optimizer, lets just
2788 sweep away the NOTE_INSN_PREDICTION notes that leaked out. */
2789 for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
2790 if (GET_CODE (insn) == NOTE
2791 && NOTE_LINE_NUMBER (insn) == NOTE_INSN_PREDICTION)
2794 close_dump_file (DFI_sibling, print_rtl, get_insns ());
2797 /* Perform jump bypassing and control flow optimizations. */
2799 rest_of_handle_jump_bypass (tree decl, rtx insns)
2801 timevar_push (TV_BYPASS);
2802 open_dump_file (DFI_bypass, decl);
2804 cleanup_cfg (CLEANUP_EXPENSIVE);
2806 if (bypass_jumps (rtl_dump_file))
2808 rebuild_jump_labels (insns);
2809 cleanup_cfg (CLEANUP_EXPENSIVE);
2810 delete_trivially_dead_insns (insns, max_reg_num ());
2813 close_dump_file (DFI_bypass, print_rtl_with_bb, insns);
2814 timevar_pop (TV_BYPASS);
2818 #ifdef ENABLE_CHECKING
2819 verify_flow_info ();
2823 /* Handle inlining of functions in rest_of_compilation. Return TRUE
2824 if we must exit rest_of_compilation upon return. */
2826 rest_of_handle_inlining (tree decl)
2833 /* If we are reconsidering an inline function at the end of
2834 compilation, skip the stuff for making it inline. */
2835 if (DECL_SAVED_INSNS (decl) != 0)
2838 /* If this is nested inside an inlined external function, pretend
2839 it was only declared. Since we cannot inline such functions,
2840 generating code for this one is not only not necessary but will
2841 confuse some debugging output writers. */
2842 for (parent = DECL_CONTEXT (current_function_decl);
2843 parent != NULL_TREE;
2844 parent = get_containing_scope (parent))
2845 if (TREE_CODE (parent) == FUNCTION_DECL
2846 && DECL_INLINE (parent) && DECL_EXTERNAL (parent))
2848 DECL_INITIAL (decl) = 0;
2851 else if (TYPE_P (parent))
2852 /* A function in a local class should be treated normally. */
2855 /* If requested, consider whether to make this function inline. */
2856 if ((DECL_INLINE (decl) && !flag_no_inline)
2857 || flag_inline_functions)
2859 timevar_push (TV_INTEGRATION);
2860 lose = function_cannot_inline_p (decl);
2861 timevar_pop (TV_INTEGRATION);
2862 if (lose || ! optimize)
2864 if (warn_inline && DECL_INLINE (decl))
2865 warning_with_decl (decl, lose);
2866 DECL_ABSTRACT_ORIGIN (decl) = 0;
2867 /* Don't really compile an extern inline function.
2868 If we can't make it inline, pretend
2869 it was only declared. */
2870 if (DECL_EXTERNAL (decl))
2872 DECL_INITIAL (decl) = 0;
2877 /* ??? Note that we used to just make it look like if
2878 the "inline" keyword was specified when we decide
2879 to inline it (because of -finline-functions).
2880 garloff@suse.de, 2002-04-24: Add another flag to
2881 actually record this piece of information. */
2882 if (!DECL_INLINE (decl))
2883 DID_INLINE_FUNC (decl) = 1;
2884 inlinable = DECL_INLINE (decl) = 1;
2888 insns = get_insns ();
2890 /* Dump the rtl code if we are dumping rtl. */
2892 if (open_dump_file (DFI_rtl, decl))
2894 if (DECL_SAVED_INSNS (decl))
2895 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2896 close_dump_file (DFI_rtl, print_rtl, insns);
2899 /* Convert from NOTE_INSN_EH_REGION style notes, and do other
2900 sorts of eh initialization. Delay this until after the
2901 initial rtl dump so that we can see the original nesting. */
2902 convert_from_eh_region_ranges ();
2904 /* If function is inline, and we don't yet know whether to
2905 compile it by itself, defer decision till end of compilation.
2906 wrapup_global_declarations will (indirectly) call
2907 rest_of_compilation again for those functions that need to
2908 be output. Also defer those functions that we are supposed
2912 || (DECL_INLINE (decl)
2913 && flag_inline_functions
2914 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2915 && ! TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))
2916 && ! flag_keep_inline_functions)
2917 || DECL_EXTERNAL (decl))))
2918 DECL_DEFER_OUTPUT (decl) = 1;
2920 if (DECL_INLINE (decl))
2921 /* DWARF wants separate debugging info for abstract and
2922 concrete instances of all inline functions, including those
2923 declared inline but not inlined, and those inlined even
2924 though they weren't declared inline. Conveniently, that's
2925 what DECL_INLINE means at this point. */
2926 (*debug_hooks->deferred_inline_function) (decl);
2928 if (DECL_DEFER_OUTPUT (decl))
2930 /* If -Wreturn-type, we have to do a bit of compilation. We just
2931 want to call cleanup the cfg to figure out whether or not we can
2932 fall off the end of the function; we do the minimum amount of
2933 work necessary to make that safe. */
2934 if (warn_return_type)
2936 int saved_optimize = optimize;
2939 rebuild_jump_labels (insns);
2940 find_exception_handler_labels ();
2941 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2942 cleanup_cfg (CLEANUP_PRE_SIBCALL | CLEANUP_PRE_LOOP);
2943 optimize = saved_optimize;
2945 /* CFG is no longer maintained up-to-date. */
2946 free_bb_for_insn ();
2949 set_nothrow_function_flags ();
2950 if (current_function_nothrow)
2951 /* Now we know that this can't throw; set the flag for the benefit
2952 of other functions later in this translation unit. */
2953 TREE_NOTHROW (current_function_decl) = 1;
2955 timevar_push (TV_INTEGRATION);
2956 save_for_inline (decl);
2957 timevar_pop (TV_INTEGRATION);
2958 DECL_SAVED_INSNS (decl)->inlinable = inlinable;
2962 /* If specified extern inline but we aren't inlining it, we are
2963 done. This goes for anything that gets here with DECL_EXTERNAL
2964 set, not just things with DECL_INLINE. */
2965 return (bool) DECL_EXTERNAL (decl);
2968 /* Rest of compilation helper to convert the rtl to SSA form. */
2970 rest_of_handle_ssa (tree decl, rtx insns)
2972 timevar_push (TV_TO_SSA);
2973 open_dump_file (DFI_ssa, decl);
2975 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2978 close_dump_file (DFI_ssa, print_rtl_with_bb, insns);
2979 timevar_pop (TV_TO_SSA);
2981 /* Perform sparse conditional constant propagation, if requested. */
2984 timevar_push (TV_SSA_CCP);
2985 open_dump_file (DFI_ssa_ccp, decl);
2989 close_dump_file (DFI_ssa_ccp, print_rtl_with_bb, get_insns ());
2990 timevar_pop (TV_SSA_CCP);
2993 /* It would be useful to cleanup the CFG at this point, but block
2994 merging and possibly other transformations might leave a PHI
2995 node in the middle of a basic block, which is a strict no-no. */
2997 /* The SSA implementation uses basic block numbers in its phi
2998 nodes. Thus, changing the control-flow graph or the basic
2999 blocks, e.g., calling find_basic_blocks () or cleanup_cfg (),
3000 may cause problems. */
3004 /* Remove dead code. */
3006 timevar_push (TV_SSA_DCE);
3007 open_dump_file (DFI_ssa_dce, decl);
3009 insns = get_insns ();
3010 ssa_eliminate_dead_code ();
3012 close_dump_file (DFI_ssa_dce, print_rtl_with_bb, insns);
3013 timevar_pop (TV_SSA_DCE);
3016 /* Convert from SSA form. */
3018 timevar_push (TV_FROM_SSA);
3019 open_dump_file (DFI_ussa, decl);
3021 convert_from_ssa ();
3022 /* New registers have been created. Rescan their usage. */
3023 reg_scan (insns, max_reg_num (), 1);
3025 close_dump_file (DFI_ussa, print_rtl_with_bb, insns);
3026 timevar_pop (TV_FROM_SSA);
3033 /* Try to identify useless null pointer tests and delete them. */
3035 rest_of_handle_null_pointer (tree decl, rtx insns)
3037 open_dump_file (DFI_null, decl);
3039 dump_flow_info (rtl_dump_file);
3041 if (delete_null_pointer_checks (insns))
3042 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
3044 close_dump_file (DFI_null, print_rtl_with_bb, insns);
3047 /* Try combining insns through substitution. */
3049 rest_of_handle_combine (tree decl, rtx insns)
3051 int rebuild_jump_labels_after_combine = 0;
3053 timevar_push (TV_COMBINE);
3054 open_dump_file (DFI_combine, decl);
3056 rebuild_jump_labels_after_combine
3057 = combine_instructions (insns, max_reg_num ());
3059 /* Combining insns may have turned an indirect jump into a
3060 direct jump. Rebuild the JUMP_LABEL fields of jumping
3062 if (rebuild_jump_labels_after_combine)
3064 timevar_push (TV_JUMP);
3065 rebuild_jump_labels (insns);
3066 timevar_pop (TV_JUMP);
3068 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
3071 close_dump_file (DFI_combine, print_rtl_with_bb, insns);
3072 timevar_pop (TV_COMBINE);
3077 /* Perform life analysis. */
3079 rest_of_handle_life (tree decl, rtx insns)
3081 open_dump_file (DFI_life, decl);
3084 #ifdef ENABLE_CHECKING
3085 verify_flow_info ();
3087 life_analysis (insns, rtl_dump_file, PROP_FINAL);
3089 cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0) | CLEANUP_UPDATE_LIFE
3090 | (flag_thread_jumps ? CLEANUP_THREADING : 0));
3091 timevar_pop (TV_FLOW);
3093 if (warn_uninitialized)
3095 uninitialized_vars_warning (DECL_INITIAL (decl));
3097 setjmp_args_warning ();
3102 if (!flag_new_regalloc && initialize_uninitialized_subregs ())
3104 /* Insns were inserted, and possibly pseudos created, so
3105 things might look a bit different. */
3106 insns = get_insns ();
3107 allocate_reg_life_data ();
3108 update_life_info (NULL, UPDATE_LIFE_GLOBAL_RM_NOTES,
3109 PROP_LOG_LINKS | PROP_REG_INFO | PROP_DEATH_NOTES);
3115 close_dump_file (DFI_life, print_rtl_with_bb, insns);
3120 /* Perform common subexpression elimination. Nonzero value from
3121 `cse_main' means that jumps were simplified and some code may now
3122 be unreachable, so do jump optimization again. */
3124 rest_of_handle_cse (tree decl, rtx insns)
3128 open_dump_file (DFI_cse, decl);
3130 dump_flow_info (rtl_dump_file);
3131 timevar_push (TV_CSE);
3133 reg_scan (insns, max_reg_num (), 1);
3135 tem = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
3137 rebuild_jump_labels (insns);
3138 purge_all_dead_edges (0);
3140 delete_trivially_dead_insns (insns, max_reg_num ());
3142 /* If we are not running more CSE passes, then we are no longer
3143 expecting CSE to be run. But always rerun it in a cheap mode. */
3144 cse_not_expected = !flag_rerun_cse_after_loop && !flag_gcse;
3146 if (tem || optimize > 1)
3147 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
3148 /* Try to identify useless null pointer tests and delete them. */
3149 if (flag_delete_null_pointer_checks)
3151 timevar_push (TV_JUMP);
3153 if (delete_null_pointer_checks (insns))
3154 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
3155 timevar_pop (TV_JUMP);
3158 /* The second pass of jump optimization is likely to have
3159 removed a bunch more instructions. */
3160 renumber_insns (rtl_dump_file);
3162 timevar_pop (TV_CSE);
3163 close_dump_file (DFI_cse, print_rtl_with_bb, insns);
3166 /* Run second CSE pass after loop optimizations. */
3168 rest_of_handle_cse2 (tree decl, rtx insns)
3172 timevar_push (TV_CSE2);
3173 open_dump_file (DFI_cse2, decl);
3175 dump_flow_info (rtl_dump_file);
3176 /* CFG is no longer maintained up-to-date. */
3177 tem = cse_main (insns, max_reg_num (), 1, rtl_dump_file);
3178 purge_all_dead_edges (0);
3179 delete_trivially_dead_insns (insns, max_reg_num ());
3183 timevar_push (TV_JUMP);
3184 rebuild_jump_labels (insns);
3185 cleanup_cfg (CLEANUP_EXPENSIVE);
3186 timevar_pop (TV_JUMP);
3188 reg_scan (insns, max_reg_num (), 0);
3189 close_dump_file (DFI_cse2, print_rtl_with_bb, insns);
3191 timevar_pop (TV_CSE2);
3194 /* Perform global cse. */
3196 rest_of_handle_gcse (tree decl, rtx insns)
3198 int save_csb, save_cfj;
3201 timevar_push (TV_GCSE);
3202 open_dump_file (DFI_gcse, decl);
3204 tem = gcse_main (insns, rtl_dump_file);
3205 rebuild_jump_labels (insns);
3206 delete_trivially_dead_insns (insns, max_reg_num ());
3208 save_csb = flag_cse_skip_blocks;
3209 save_cfj = flag_cse_follow_jumps;
3210 flag_cse_skip_blocks = flag_cse_follow_jumps = 0;
3212 /* Instantiate any remaining CONSTANT_P_RTX nodes. */
3213 if (current_function_calls_constant_p)
3214 purge_builtin_constant_p ();
3216 /* If -fexpensive-optimizations, re-run CSE to clean up things done
3218 if (flag_expensive_optimizations)
3220 timevar_push (TV_CSE);
3221 reg_scan (insns, max_reg_num (), 1);
3222 tem2 = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
3223 purge_all_dead_edges (0);
3224 delete_trivially_dead_insns (insns, max_reg_num ());
3225 timevar_pop (TV_CSE);
3226 cse_not_expected = !flag_rerun_cse_after_loop;
3229 /* If gcse or cse altered any jumps, rerun jump optimizations to clean
3230 things up. Then possibly re-run CSE again. */
3234 timevar_push (TV_JUMP);
3235 rebuild_jump_labels (insns);
3236 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
3237 timevar_pop (TV_JUMP);
3239 if (flag_expensive_optimizations)
3241 timevar_push (TV_CSE);
3242 reg_scan (insns, max_reg_num (), 1);
3243 tem2 = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
3244 purge_all_dead_edges (0);
3245 delete_trivially_dead_insns (insns, max_reg_num ());
3246 timevar_pop (TV_CSE);
3250 close_dump_file (DFI_gcse, print_rtl_with_bb, insns);
3251 timevar_pop (TV_GCSE);
3254 flag_cse_skip_blocks = save_csb;
3255 flag_cse_follow_jumps = save_cfj;
3256 #ifdef ENABLE_CHECKING
3257 verify_flow_info ();
3261 /* Move constant computations out of loops. */
3263 rest_of_handle_loop_optimize (tree decl, rtx insns)
3265 int do_unroll, do_prefetch;
3267 timevar_push (TV_LOOP);
3268 delete_dead_jumptables ();
3269 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
3270 open_dump_file (DFI_loop, decl);
3272 /* CFG is no longer maintained up-to-date. */
3273 free_bb_for_insn ();
3275 if (flag_unroll_loops)
3276 do_unroll = 0; /* Having two unrollers is useless. */
3278 do_unroll = flag_old_unroll_loops ? LOOP_UNROLL : LOOP_AUTO_UNROLL;
3279 do_prefetch = flag_prefetch_loop_arrays ? LOOP_PREFETCH : 0;
3281 if (flag_rerun_loop_opt)
3283 cleanup_barriers ();
3285 /* We only want to perform unrolling once. */
3286 loop_optimize (insns, rtl_dump_file, do_unroll);
3289 /* The first call to loop_optimize makes some instructions
3290 trivially dead. We delete those instructions now in the
3291 hope that doing so will make the heuristics in loop work
3292 better and possibly speed up compilation. */
3293 delete_trivially_dead_insns (insns, max_reg_num ());
3295 /* The regscan pass is currently necessary as the alias
3296 analysis code depends on this information. */
3297 reg_scan (insns, max_reg_num (), 1);
3299 cleanup_barriers ();
3300 loop_optimize (insns, rtl_dump_file, do_unroll | LOOP_BCT | do_prefetch);
3302 /* Loop can create trivially dead instructions. */
3303 delete_trivially_dead_insns (insns, max_reg_num ());
3304 close_dump_file (DFI_loop, print_rtl, insns);
3305 timevar_pop (TV_LOOP);
3306 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3311 /* Perform loop optimizations. It might be better to do them a bit
3312 sooner, but we want the profile feedback to work more
3315 rest_of_handle_loop2 (tree decl, rtx insns)
3317 struct loops *loops;
3318 timevar_push (TV_LOOP);
3319 open_dump_file (DFI_loop2, decl);
3321 dump_flow_info (rtl_dump_file);
3323 loops = loop_optimizer_init (rtl_dump_file);
3327 /* The optimizations: */
3328 if (flag_unswitch_loops)
3329 unswitch_loops (loops);
3331 if (flag_peel_loops || flag_unroll_loops)
3332 unroll_and_peel_loops (loops,
3333 (flag_peel_loops ? UAP_PEEL : 0) |
3334 (flag_unroll_loops ? UAP_UNROLL : 0) |
3335 (flag_unroll_all_loops ? UAP_UNROLL_ALL : 0));
3337 loop_optimizer_finalize (loops, rtl_dump_file);
3340 cleanup_cfg (CLEANUP_EXPENSIVE);
3341 delete_trivially_dead_insns (insns, max_reg_num ());
3342 reg_scan (insns, max_reg_num (), 0);
3344 dump_flow_info (rtl_dump_file);
3345 close_dump_file (DFI_loop2, print_rtl_with_bb, get_insns ());
3346 timevar_pop (TV_LOOP);
3350 /* This is called from finish_function (within langhooks.parse_file)
3351 after each top-level definition is parsed.
3352 It is supposed to compile that function or variable
3353 and output the assembler code for it.
3354 After we return, the tree storage is freed. */
3357 rest_of_compilation (tree decl)
3360 int rebuild_label_notes_after_reload;
3362 timevar_push (TV_REST_OF_COMPILATION);
3364 /* Register rtl specific functions for cfg. */
3365 rtl_register_cfg_hooks ();
3367 /* Now that we're out of the frontend, we shouldn't have any more
3368 CONCATs anywhere. */
3369 generating_concat_p = 0;
3371 /* When processing delayed functions, prepare_function_start() won't
3372 have been run to re-initialize it. */
3373 cse_not_expected = ! optimize;
3375 /* First, make sure that NOTE_BLOCK is set correctly for each
3376 NOTE_INSN_BLOCK_BEG/NOTE_INSN_BLOCK_END note. */
3377 if (!cfun->x_whole_function_mode_p)
3380 /* In function-at-a-time mode, we do not attempt to keep the BLOCK
3381 tree in sensible shape. So, we just recalculate it here. */
3382 if (cfun->x_whole_function_mode_p)
3387 if (rest_of_handle_inlining (decl))
3388 goto exit_rest_of_compilation;
3390 /* If we're emitting a nested function, make sure its parent gets
3391 emitted as well. Doing otherwise confuses debug info. */
3394 for (parent = DECL_CONTEXT (current_function_decl);
3395 parent != NULL_TREE;
3396 parent = get_containing_scope (parent))
3397 if (TREE_CODE (parent) == FUNCTION_DECL)
3398 TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (parent)) = 1;
3401 /* We are now committed to emitting code for this function. Do any
3402 preparation, such as emitting abstract debug info for the inline
3403 before it gets mangled by optimization. */
3404 if (DECL_INLINE (decl))
3405 (*debug_hooks->outlining_inline_function) (decl);
3407 /* Remove any notes we don't need. That will make iterating
3408 over the instruction sequence faster, and allow the garbage
3409 collector to reclaim the memory used by the notes. */
3410 remove_unnecessary_notes ();
3415 /* Initialize some variables used by the optimizers. */
3416 init_function_for_compilation ();
3418 if (! DECL_DEFER_OUTPUT (decl))
3419 TREE_ASM_WRITTEN (decl) = 1;
3421 /* Now that integrate will no longer see our rtl, we need not
3422 distinguish between the return value of this function and the
3423 return value of called functions. Also, we can remove all SETs
3424 of subregs of hard registers; they are only here because of
3425 integrate. Also, we can now initialize pseudos intended to
3426 carry magic hard reg data throughout the function. */
3427 rtx_equal_function_value_matters = 0;
3428 purge_hard_subreg_sets (get_insns ());
3430 /* Early return if there were errors. We can run afoul of our
3431 consistency checks, and there's not really much point in fixing them.
3432 Don't return yet if -Wreturn-type; we need to do cleanup_cfg. */
3433 if (((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
3434 || errorcount || sorrycount)
3435 goto exit_rest_of_compilation;
3437 timevar_push (TV_JUMP);
3438 open_dump_file (DFI_sibling, decl);
3439 insns = get_insns ();
3440 rebuild_jump_labels (insns);
3441 find_exception_handler_labels ();
3442 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3444 delete_unreachable_blocks ();
3446 /* We have to issue these warnings now already, because CFG cleanups
3447 further down may destroy the required information. */
3448 check_function_return_warnings ();
3450 /* Turn NOTE_INSN_PREDICTIONs into branch predictions. */
3451 if (flag_guess_branch_prob)
3453 timevar_push (TV_BRANCH_PROB);
3454 note_prediction_to_br_prob ();
3455 timevar_pop (TV_BRANCH_PROB);
3458 if (flag_optimize_sibling_calls)
3459 rest_of_handle_sibling_calls (insns);
3461 timevar_pop (TV_JUMP);
3463 insn_locators_initialize ();
3464 /* Complete generation of exception handling code. */
3467 timevar_push (TV_JUMP);
3468 open_dump_file (DFI_eh, decl);
3470 finish_eh_generation ();
3472 close_dump_file (DFI_eh, print_rtl, get_insns ());
3473 timevar_pop (TV_JUMP);
3476 /* Delay emitting hard_reg_initial_value sets until after EH landing pad
3477 generation, which might create new sets. */
3478 emit_initial_value_sets ();
3481 /* If we are doing position-independent code generation, now
3482 is the time to output special prologues and epilogues.
3483 We do not want to do this earlier, because it just clutters
3484 up inline functions with meaningless insns. */
3489 insns = get_insns ();
3491 /* Copy any shared structure that should not be shared. */
3492 unshare_all_rtl (current_function_decl, insns);
3494 #ifdef SETJMP_VIA_SAVE_AREA
3495 /* This must be performed before virtual register instantiation.
3496 Please be aware the everything in the compiler that can look
3497 at the RTL up to this point must understand that REG_SAVE_AREA
3498 is just like a use of the REG contained inside. */
3499 if (current_function_calls_alloca)
3500 optimize_save_area_alloca (insns);
3503 /* Instantiate all virtual registers. */
3504 instantiate_virtual_regs (current_function_decl, insns);
3506 open_dump_file (DFI_jump, decl);
3508 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
3509 are initialized and to compute whether control can drop off the end
3512 timevar_push (TV_JUMP);
3513 /* Turn NOTE_INSN_EXPECTED_VALUE into REG_BR_PROB. Do this
3514 before jump optimization switches branch directions. */
3515 if (flag_guess_branch_prob)
3516 expected_value_to_br_prob ();
3518 reg_scan (insns, max_reg_num (), 0);
3519 rebuild_jump_labels (insns);
3520 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3521 delete_trivially_dead_insns (insns, max_reg_num ());
3523 dump_flow_info (rtl_dump_file);
3524 cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0) | CLEANUP_PRE_LOOP
3525 | (flag_thread_jumps ? CLEANUP_THREADING : 0));
3529 free_bb_for_insn ();
3530 copy_loop_headers (insns);
3531 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3533 purge_line_number_notes (insns);
3535 timevar_pop (TV_JUMP);
3536 close_dump_file (DFI_jump, print_rtl, insns);
3538 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
3539 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
3540 goto exit_rest_of_compilation;
3542 /* Long term, this should probably move before the jump optimizer too,
3543 but I didn't want to disturb the rtl_dump_and_exit and related
3544 stuff at this time. */
3545 if (optimize > 0 && flag_ssa)
3546 insns = rest_of_handle_ssa (decl, insns);
3548 timevar_push (TV_JUMP);
3551 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
3553 if (flag_delete_null_pointer_checks)
3554 rest_of_handle_null_pointer (decl, insns);
3556 /* Jump optimization, and the removal of NULL pointer checks, may
3557 have reduced the number of instructions substantially. CSE, and
3558 future passes, allocate arrays whose dimensions involve the
3559 maximum instruction UID, so if we can reduce the maximum UID
3560 we'll save big on memory. */
3561 renumber_insns (rtl_dump_file);
3562 timevar_pop (TV_JUMP);
3564 close_dump_file (DFI_jump, print_rtl_with_bb, insns);
3569 rest_of_handle_cse (decl, insns);
3571 rest_of_handle_addresof (decl, insns);
3578 rest_of_handle_gcse (decl, insns);
3580 if (flag_loop_optimize)
3581 rest_of_handle_loop_optimize (decl, insns);
3584 rest_of_handle_jump_bypass (decl, insns);
3587 timevar_push (TV_FLOW);
3589 rest_of_handle_cfg (decl, insns);
3592 || profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
3593 rest_of_handle_branch_prob (decl, insns);
3596 rest_of_handle_if_conversion (decl, insns);
3599 rest_of_handle_tracer (decl, insns);
3602 && (flag_unswitch_loops
3604 || flag_unroll_loops))
3605 rest_of_handle_loop2 (decl, insns);
3607 if (flag_rerun_cse_after_loop)
3608 rest_of_handle_cse2 (decl, insns);
3610 cse_not_expected = 1;
3612 rest_of_handle_life (decl, insns);
3615 rest_of_handle_combine (decl, insns);
3617 if (flag_if_conversion)
3618 rest_of_handle_if_after_combine (decl, insns);
3620 if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
3621 rest_of_handle_regmove (decl, insns);
3623 /* Do unconditional splitting before register allocation to allow machine
3624 description to add extra information not needed previously. */
3625 split_all_insns (1);
3627 #ifdef OPTIMIZE_MODE_SWITCHING
3628 timevar_push (TV_MODE_SWITCH);
3631 optimize_mode_switching (NULL);
3634 timevar_pop (TV_MODE_SWITCH);
3637 /* Any of the several passes since flow1 will have munged register
3638 lifetime data a bit. We need it to be up to date for scheduling
3639 (see handling of reg_known_equiv in init_alias_analysis). */
3640 recompute_reg_usage (insns, !optimize_size);
3642 #ifdef INSN_SCHEDULING
3643 rest_of_handle_sched (decl, insns);
3646 /* Determine if the current function is a leaf before running reload
3647 since this can impact optimizations done by the prologue and
3648 epilogue thus changing register elimination offsets. */
3649 current_function_is_leaf = leaf_function_p ();
3651 timevar_push (TV_LOCAL_ALLOC);
3652 open_dump_file (DFI_lreg, decl);
3654 if (flag_new_regalloc)
3656 if (rest_of_handle_new_regalloc (decl, insns,
3657 &rebuild_label_notes_after_reload))
3658 goto exit_rest_of_compilation;
3662 if (rest_of_handle_old_regalloc (decl, insns,
3663 &rebuild_label_notes_after_reload))
3664 goto exit_rest_of_compilation;
3669 open_dump_file (DFI_postreload, decl);
3671 /* Do a very simple CSE pass over just the hard registers. */
3674 timevar_push (TV_RELOAD_CSE_REGS);
3675 reload_cse_regs (insns);
3676 timevar_pop (TV_RELOAD_CSE_REGS);
3679 /* Register allocation and reloading may have turned an indirect jump into
3680 a direct jump. If so, we must rebuild the JUMP_LABEL fields of
3681 jumping instructions. */
3682 if (rebuild_label_notes_after_reload)
3684 timevar_push (TV_JUMP);
3686 rebuild_jump_labels (insns);
3687 purge_all_dead_edges (0);
3689 timevar_pop (TV_JUMP);
3692 close_dump_file (DFI_postreload, print_rtl_with_bb, insns);
3694 /* Re-create the death notes which were deleted during reload. */
3695 timevar_push (TV_FLOW2);
3696 open_dump_file (DFI_flow2, decl);
3698 #ifdef ENABLE_CHECKING
3699 verify_flow_info ();
3702 /* If optimizing, then go ahead and split insns now. */
3706 split_all_insns (0);
3708 if (flag_branch_target_load_optimize)
3710 open_dump_file (DFI_branch_target_load, decl);
3712 branch_target_load_optimize (insns, false);
3714 close_dump_file (DFI_branch_target_load, print_rtl_with_bb, insns);
3720 cleanup_cfg (CLEANUP_EXPENSIVE);
3722 /* On some machines, the prologue and epilogue code, or parts thereof,
3723 can be represented as RTL. Doing so lets us schedule insns between
3724 it and the rest of the code and also allows delayed branch
3725 scheduling to operate in the epilogue. */
3726 thread_prologue_and_epilogue_insns (insns);
3727 epilogue_completed = 1;
3731 life_analysis (insns, rtl_dump_file, PROP_FINAL);
3732 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE
3733 | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0));
3735 /* This is kind of a heuristic. We need to run combine_stack_adjustments
3736 even for machines with possibly nonzero RETURN_POPS_ARGS
3737 and ACCUMULATE_OUTGOING_ARGS. We expect that only ports having
3738 push instructions will have popping returns. */
3739 #ifndef PUSH_ROUNDING
3740 if (!ACCUMULATE_OUTGOING_ARGS)
3742 combine_stack_adjustments ();
3747 flow2_completed = 1;
3749 close_dump_file (DFI_flow2, print_rtl_with_bb, insns);
3750 timevar_pop (TV_FLOW2);
3752 #ifdef HAVE_peephole2
3753 if (optimize > 0 && flag_peephole2)
3755 timevar_push (TV_PEEPHOLE2);
3756 open_dump_file (DFI_peephole2, decl);
3758 peephole2_optimize (rtl_dump_file);
3760 close_dump_file (DFI_peephole2, print_rtl_with_bb, insns);
3761 timevar_pop (TV_PEEPHOLE2);
3767 if (flag_rename_registers || flag_cprop_registers)
3768 rest_of_handle_regrename (decl, insns);
3770 rest_of_handle_reorder_blocks (decl, insns);
3773 if (flag_if_conversion2)
3775 timevar_push (TV_IFCVT2);
3776 open_dump_file (DFI_ce3, decl);
3780 close_dump_file (DFI_ce3, print_rtl_with_bb, insns);
3781 timevar_pop (TV_IFCVT2);
3784 if (flag_branch_target_load_optimize2)
3786 /* Leave this a warning for now so that it is possible to experiment
3787 with running this pass twice. In 3.6, we should either make this
3788 an error, or use separate dump files. */
3789 if (flag_branch_target_load_optimize)
3790 warning ("branch target register load optimization is not intended "
3793 open_dump_file (DFI_branch_target_load, decl);
3795 branch_target_load_optimize (insns, true);
3797 close_dump_file (DFI_branch_target_load, print_rtl_with_bb, insns);
3802 #ifdef INSN_SCHEDULING
3803 if (optimize > 0 && flag_schedule_insns_after_reload)
3804 rest_of_handle_sched2 (decl, insns);
3807 #ifdef LEAF_REGISTERS
3808 current_function_uses_only_leaf_regs
3809 = optimize > 0 && only_leaf_regs_used () && leaf_function_p ();
3813 rest_of_handle_stack_regs (decl, insns);
3816 compute_alignments ();
3818 /* CFG is no longer maintained up-to-date. */
3819 free_bb_for_insn ();
3821 if (targetm.machine_dependent_reorg != 0)
3822 rest_of_handle_machine_reorg (decl, insns);
3824 purge_line_number_notes (insns);
3825 cleanup_barriers ();
3828 if (optimize > 0 && flag_delayed_branch)
3829 rest_of_handle_delay_slots (decl, insns);
3832 #if defined (HAVE_ATTR_length) && !defined (STACK_REGS)
3833 timevar_push (TV_SHORTEN_BRANCH);
3834 split_all_insns_noflow ();
3835 timevar_pop (TV_SHORTEN_BRANCH);
3838 convert_to_eh_region_ranges ();
3840 /* Shorten branches. */
3841 timevar_push (TV_SHORTEN_BRANCH);
3842 shorten_branches (get_insns ());
3843 timevar_pop (TV_SHORTEN_BRANCH);
3845 set_nothrow_function_flags ();
3846 if (current_function_nothrow)
3847 /* Now we know that this can't throw; set the flag for the benefit
3848 of other functions later in this translation unit. */
3849 TREE_NOTHROW (current_function_decl) = 1;
3851 rest_of_handle_final (decl, insns);
3853 /* Write DBX symbols if requested. */
3855 /* Note that for those inline functions where we don't initially
3856 know for certain that we will be generating an out-of-line copy,
3857 the first invocation of this routine (rest_of_compilation) will
3858 skip over this code by doing a `goto exit_rest_of_compilation;'.
3859 Later on, wrapup_global_declarations will (indirectly) call
3860 rest_of_compilation again for those inline functions that need
3861 to have out-of-line copies generated. During that call, we
3862 *will* be routed past here. */
3864 timevar_push (TV_SYMOUT);
3865 (*debug_hooks->function_decl) (decl);
3866 timevar_pop (TV_SYMOUT);
3868 exit_rest_of_compilation:
3870 coverage_end_function ();
3872 /* In case the function was not output,
3873 don't leave any temporary anonymous types
3874 queued up for sdb output. */
3875 #ifdef SDB_DEBUGGING_INFO
3876 if (write_symbols == SDB_DEBUG)
3877 sdbout_types (NULL_TREE);
3880 reload_completed = 0;
3881 epilogue_completed = 0;
3882 flow2_completed = 0;
3885 timevar_push (TV_FINAL);
3887 /* Clear out the insn_length contents now that they are no
3889 init_insn_lengths ();
3891 /* Show no temporary slots allocated. */
3894 free_basic_block_vars (0);
3895 free_bb_for_insn ();
3897 timevar_pop (TV_FINAL);
3899 if ((*targetm.binds_local_p) (current_function_decl))
3901 int pref = cfun->preferred_stack_boundary;
3902 if (cfun->recursive_call_emit
3903 && cfun->stack_alignment_needed > cfun->preferred_stack_boundary)
3904 pref = cfun->stack_alignment_needed;
3905 cgraph_rtl_info (current_function_decl)->preferred_incoming_stack_boundary
3909 /* Make sure volatile mem refs aren't considered valid operands for
3910 arithmetic insns. We must call this here if this is a nested inline
3911 function, since the above code leaves us in the init_recog state
3912 (from final.c), and the function context push/pop code does not
3913 save/restore volatile_ok.
3915 ??? Maybe it isn't necessary for expand_start_function to call this
3916 anymore if we do it here? */
3918 init_recog_no_volatile ();
3920 /* We're done with this function. Free up memory if we can. */
3921 free_after_parsing (cfun);
3922 if (! DECL_DEFER_OUTPUT (decl))
3924 free_after_compilation (cfun);
3926 /* Clear integrate.c's pointer to the cfun structure we just
3928 DECL_SAVED_INSNS (decl) = 0;
3934 timevar_pop (TV_REST_OF_COMPILATION);
3937 /* Display help for generic options. */
3945 printf (_(" -ffixed-<register> Mark <register> as being unavailable to the compiler\n"));
3946 printf (_(" -fcall-used-<register> Mark <register> as being corrupted by function calls\n"));
3947 printf (_(" -fcall-saved-<register> Mark <register> as being preserved across functions\n"));
3948 printf (_(" -finline-limit=<number> Limits the size of inlined functions to <number>\n"));
3949 printf (_(" -fmessage-length=<number> Limits diagnostics messages lengths to <number> characters per line. 0 suppresses line-wrapping\n"));
3950 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"));
3951 printf (_(" -ftls-model=[global-dynamic | local-dynamic | initial-exec | local-exec] Indicates the default thread-local storage code generation model\n"));
3952 printf (_(" -fstack-limit-register=<register> Trap if the stack goes past <register>\n"));
3953 printf (_(" -fstack-limit-symbol=<name> Trap if the stack goes past symbol <name>\n"));
3954 printf (_(" -frandom-seed=<string> Make compile reproducible using <string>\n"));
3957 for (i = ARRAY_SIZE (f_options); i--;)
3959 const char *description = f_options[i].description;
3961 if (description != NULL && *description != 0)
3962 printf (" -f%-21s %s\n",
3963 f_options[i].string, _(description));
3966 printf (_(" -O[number] Set optimization level to [number]\n"));
3967 printf (_(" -Os Optimize for space rather than speed\n"));
3968 for (i = LAST_PARAM; i--;)
3970 const char *description = compiler_params[i].help;
3971 const int length = 21 - strlen (compiler_params[i].option);
3973 if (description != NULL && *description != 0)
3974 printf (" --param %s=<value>%.*s%s\n",
3975 compiler_params[i].option,
3976 length > 0 ? length : 1, " ",
3979 printf (_(" -pedantic Issue warnings needed by strict compliance to ISO C\n"));
3980 printf (_(" -pedantic-errors Like -pedantic except that errors are produced\n"));
3981 printf (_(" -w Suppress warnings\n"));
3983 for (i = ARRAY_SIZE (W_options); i--;)
3985 const char *description = W_options[i].description;
3987 if (description != NULL && *description != 0)
3988 printf (" -W%-21s %s\n",
3989 W_options[i].string, _(description));
3992 printf (_(" -Wextra Print extra (possibly unwanted) warnings\n"));
3993 printf (_(" -Wunused Enable unused warnings\n"));
3994 printf (_(" -Wlarger-than-<number> Warn if an object is larger than <number> bytes\n"));
3995 printf (_(" -p Enable function profiling\n"));
3996 printf (_(" -o <file> Place output into <file> \n"));
3998 -G <number> Put global and static data smaller than <number>\n\
3999 bytes into a special section (on some targets)\n"));
4001 for (i = ARRAY_SIZE (debug_args); i--;)
4003 if (debug_args[i].description != NULL)
4004 printf (" -g%-21s %s\n",
4005 debug_args[i].arg, _(debug_args[i].description));
4008 printf (_(" -aux-info <file> Emit declaration info into <file>\n"));
4009 printf (_(" -quiet Do not display functions compiled or elapsed time\n"));
4010 printf (_(" -version Display the compiler's version\n"));
4011 printf (_(" -d[letters] Enable dumps from specific passes of the compiler\n"));
4012 printf (_(" -dumpbase <file> Base name to be used for dumps from specific passes\n"));
4013 #if defined INSN_SCHEDULING
4014 printf (_(" -fsched-verbose=<number> Set the verbosity level of the scheduler\n"));
4016 printf (_(" --help Display this information\n"));
4021 /* Display descriptions of language specific options.
4022 If there is no description, note that there is an undocumented option.
4023 If the description is empty, do not display anything. (This allows
4024 options to be deliberately undocumented, for whatever reason).
4025 If the option string is missing, then this is a marker, indicating
4026 that the description string is in fact the name of a language, whose
4027 language specific options are to follow. */
4029 if (ARRAY_SIZE (documented_lang_options) > 1)
4031 printf (_("\nLanguage specific options:\n"));
4033 for (i = 0; i < ARRAY_SIZE (documented_lang_options); i++)
4035 const char *description = documented_lang_options[i].description;
4036 const char *option = documented_lang_options[i].option;
4038 if (description == NULL)
4043 printf (_(" %-23.23s [undocumented]\n"), option);
4045 else if (*description == 0)
4047 else if (option == NULL)
4051 (_("\nThere are undocumented %s specific options as well.\n"),
4055 printf (_("\n Options for %s:\n"), description);
4060 printf (" %-23.23s %s\n", option, _(description));
4065 printf (_("\nThere are undocumented %s specific options as well.\n"),
4068 display_target_options ();
4071 /* Display help for target options. */
4073 display_target_options (void)
4076 static bool displayed = false;
4078 /* Avoid double printing for --help --target-help. */
4084 if (ARRAY_SIZE (target_switches) > 1
4085 #ifdef TARGET_OPTIONS
4086 || ARRAY_SIZE (target_options) > 1
4094 printf (_("\nTarget specific options:\n"));
4096 for (i = ARRAY_SIZE (target_switches); i--;)
4098 const char *option = target_switches[i].name;
4099 const char *description = target_switches[i].description;
4101 if (option == NULL || *option == 0)
4103 else if (description == NULL)
4108 printf (_(" -m%-23.23s [undocumented]\n"), option);
4110 else if (*description != 0)
4111 doc += printf (" -m%-23.23s %s\n", option, _(description));
4114 #ifdef TARGET_OPTIONS
4115 for (i = ARRAY_SIZE (target_options); i--;)
4117 const char *option = target_options[i].prefix;
4118 const char *description = target_options[i].description;
4120 if (option == NULL || *option == 0)
4122 else if (description == NULL)
4127 printf (_(" -m%-23.23s [undocumented]\n"), option);
4129 else if (*description != 0)
4130 doc += printf (" -m%-23.23s %s\n", option, _(description));
4136 printf (_("\nThere are undocumented target specific options as well.\n"));
4138 printf (_(" They exist, but they are not documented.\n"));
4143 /* Parse a -d... command line switch. */
4146 decode_d_option (const char *arg)
4154 for (i = 0; i < (int) DFI_MAX; ++i)
4155 dump_file[i].enabled = 1;
4161 flag_print_asm_name = 1;
4164 flag_dump_rtl_in_asm = 1;
4165 flag_print_asm_name = 1;
4168 graph_dump_format = vcg;
4171 rtl_dump_and_exit = 1;
4176 case 'D': /* These are handled by the preprocessor. */
4180 setup_core_dumping();
4185 for (i = 0; i < (int) DFI_MAX; ++i)
4186 if (c == dump_file[i].debug_switch)
4188 dump_file[i].enabled = 1;
4193 warning ("unrecognized gcc debugging option: %c", c);
4198 /* Indexed by enum debug_info_type. */
4199 const char *const debug_type_names[] =
4201 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff", "vms"
4204 /* Parse a -g... command line switch. ARG is the value after the -g.
4205 It is safe to access 'ARG - 2' to generate the full switch name.
4206 Return the number of strings consumed. */
4209 decode_g_option (const char *arg)
4211 static unsigned level = 0;
4212 /* A lot of code assumes write_symbols == NO_DEBUG if the
4213 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track
4214 of what debugging type has been selected). This records the
4215 selected type. It is an error to specify more than one
4217 static enum debug_info_type selected_debug_type = NO_DEBUG;
4218 /* Nonzero if debugging format has been explicitly set.
4219 -g and -ggdb don't explicitly set the debugging format so
4220 -gdwarf -g3 is equivalent to -gdwarf3. */
4221 static int type_explicitly_set_p = 0;
4223 /* The maximum admissible debug level value. */
4224 static const unsigned max_debug_level = 3;
4226 /* Look up ARG in the table. */
4227 for (da = debug_args; da->arg; da++)
4229 const int da_len = strlen (da->arg);
4231 if (da_len == 0 || ! strncmp (arg, da->arg, da_len))
4233 enum debug_info_type type = da->debug_type;
4234 const char *p = arg + da_len;
4236 if (*p && ! ISDIGIT (*p))
4239 /* A debug flag without a level defaults to level 2.
4240 Note we do not want to call read_integral_parameter
4241 for that case since it will call atoi which
4244 ??? We may want to generalize the interface to
4245 read_integral_parameter to better handle this case
4246 if this case shows up often. */
4248 level = read_integral_parameter (p, 0, max_debug_level + 1);
4250 level = (level == 0) ? 2 : level;
4252 if (da_len > 1 && *p && !strncmp (arg, "dwarf", da_len))
4254 error ("use -gdwarf -g%d for DWARF v1, level %d",
4257 error ("use -gdwarf-2 for DWARF v2");
4260 if (level > max_debug_level)
4263 ignoring option `%s' due to invalid debug level specification",
4265 level = debug_info_level;
4268 if (type == NO_DEBUG)
4270 type = PREFERRED_DEBUGGING_TYPE;
4272 if (da_len > 1 && strncmp (arg, "gdb", da_len) == 0)
4274 #ifdef DWARF2_DEBUGGING_INFO
4275 type = DWARF2_DEBUG;
4277 #ifdef DBX_DEBUGGING_INFO
4284 if (type == NO_DEBUG)
4285 warning ("`%s': unknown or unsupported -g option", arg - 2);
4287 /* Does it conflict with an already selected type? */
4288 if (type_explicitly_set_p
4289 /* -g/-ggdb don't conflict with anything. */
4290 && da->debug_type != NO_DEBUG
4291 && type != selected_debug_type)
4292 warning ("`%s' ignored, conflicts with `-g%s'",
4293 arg - 2, debug_type_names[(int) selected_debug_type]);
4296 /* If the format has already been set, -g/-ggdb
4297 only change the debug level. */
4298 if (type_explicitly_set_p && da->debug_type == NO_DEBUG)
4299 /* Don't change debugging type. */
4303 selected_debug_type = type;
4304 type_explicitly_set_p = da->debug_type != NO_DEBUG;
4307 write_symbols = (level == 0
4309 : selected_debug_type);
4310 use_gnu_debug_info_extensions = da->use_extensions_p;
4311 debug_info_level = (enum debug_info_level) level;
4319 warning ("`-g%s': unknown or unsupported -g option", arg);
4322 /* Decode -m switches. */
4323 /* Decode the switch -mNAME. */
4326 set_target_switch (const char *name)
4329 int valid_target_option = 0;
4331 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
4332 if (!strcmp (target_switches[j].name, name))
4334 if (target_switches[j].value < 0)
4335 target_flags &= ~-target_switches[j].value;
4337 target_flags |= target_switches[j].value;
4340 if (target_switches[j].value < 0)
4341 target_flags_explicit |= -target_switches[j].value;
4343 target_flags_explicit |= target_switches[j].value;
4345 valid_target_option = 1;
4348 #ifdef TARGET_OPTIONS
4349 if (!valid_target_option)
4350 for (j = 0; j < ARRAY_SIZE (target_options); j++)
4352 int len = strlen (target_options[j].prefix);
4353 if (target_options[j].value)
4355 if (!strcmp (target_options[j].prefix, name))
4357 *target_options[j].variable = target_options[j].value;
4358 valid_target_option = 1;
4363 if (!strncmp (target_options[j].prefix, name, len))
4365 *target_options[j].variable = name + len;
4366 valid_target_option = 1;
4372 if (!valid_target_option)
4373 error ("invalid option `%s'", name);
4376 /* Print version information to FILE.
4377 Each line begins with INDENT (for the case where FILE is the
4378 assembler output file). */
4381 print_version (FILE *file, const char *indent)
4384 #define __VERSION__ "[?]"
4388 "%s%s%s version %s (%s)\n%s\tcompiled by GNU C version %s.\n"
4390 "%s%s%s version %s (%s) compiled by CC.\n"
4392 , indent, *indent != 0 ? " " : "",
4393 lang_hooks.name, version_string, TARGET_NAME,
4394 indent, __VERSION__);
4395 fnotice (file, "%s%sGGC heuristics: --param ggc-min-expand=%d --param ggc-min-heapsize=%d\n",
4396 indent, *indent != 0 ? " " : "",
4397 PARAM_VALUE (GGC_MIN_EXPAND), PARAM_VALUE (GGC_MIN_HEAPSIZE));
4400 /* Print an option value and return the adjusted position in the line.
4401 ??? We don't handle error returns from fprintf (disk full); presumably
4402 other code will catch a disk full though. */
4405 print_single_switch (FILE *file, int pos, int max,
4406 const char *indent, const char *sep, const char *term,
4407 const char *type, const char *name)
4409 /* The ultrix fprintf returns 0 on success, so compute the result we want
4410 here since we need it for the following test. */
4411 int len = strlen (sep) + strlen (type) + strlen (name);
4416 fprintf (file, "%s", term);
4421 fprintf (file, "%s", indent);
4422 pos = strlen (indent);
4424 fprintf (file, "%s%s%s", sep, type, name);
4429 /* Print active target switches to FILE.
4430 POS is the current cursor position and MAX is the size of a "line".
4431 Each line begins with INDENT and ends with TERM.
4432 Each switch is separated from the next by SEP. */
4435 print_switch_values (FILE *file, int pos, int max,
4436 const char *indent, const char *sep, const char *term)
4441 /* Fill in the -frandom-seed option, if the user didn't pass it, so
4442 that it can be printed below. This helps reproducibility. */
4445 /* Print the options as passed. */
4446 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
4447 _("options passed: "), "");
4449 for (p = &save_argv[1]; *p != NULL; p++)
4453 if (strcmp (*p, "-o") == 0)
4459 if (strcmp (*p, "-quiet") == 0)
4461 if (strcmp (*p, "-version") == 0)
4466 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
4469 fprintf (file, "%s", term);
4471 /* Print the -f and -m options that have been enabled.
4472 We don't handle language specific options but printing argv
4475 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
4476 _("options enabled: "), "");
4478 for (j = 0; j < ARRAY_SIZE (f_options); j++)
4479 if (*f_options[j].variable == f_options[j].on_value)
4480 pos = print_single_switch (file, pos, max, indent, sep, term,
4481 "-f", f_options[j].string);
4483 /* Print target specific options. */
4485 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
4486 if (target_switches[j].name[0] != '\0'
4487 && target_switches[j].value > 0
4488 && ((target_switches[j].value & target_flags)
4489 == target_switches[j].value))
4491 pos = print_single_switch (file, pos, max, indent, sep, term,
4492 "-m", target_switches[j].name);
4495 #ifdef TARGET_OPTIONS
4496 for (j = 0; j < ARRAY_SIZE (target_options); j++)
4497 if (*target_options[j].variable != NULL)
4500 sprintf (prefix, "-m%s", target_options[j].prefix);
4501 pos = print_single_switch (file, pos, max, indent, sep, term,
4502 prefix, *target_options[j].variable);
4506 fprintf (file, "%s", term);
4509 /* Open assembly code output file. Do this even if -fsyntax-only is
4510 on, because then the driver will have provided the name of a
4511 temporary file or bit bucket for us. NAME is the file specified on
4512 the command line, possibly NULL. */
4514 init_asm_output (const char *name)
4516 if (name == NULL && asm_file_name == 0)
4517 asm_out_file = stdout;
4520 if (asm_file_name == 0)
4522 int len = strlen (dump_base_name);
4523 char *dumpname = (char *) xmalloc (len + 6);
4524 memcpy (dumpname, dump_base_name, len + 1);
4525 strip_off_ending (dumpname, len);
4526 strcat (dumpname, ".s");
4527 asm_file_name = dumpname;
4529 if (!strcmp (asm_file_name, "-"))
4530 asm_out_file = stdout;
4532 asm_out_file = fopen (asm_file_name, "w+");
4533 if (asm_out_file == 0)
4534 fatal_error ("can't open %s for writing: %m", asm_file_name);
4537 #ifdef IO_BUFFER_SIZE
4538 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
4539 _IOFBF, IO_BUFFER_SIZE);
4542 if (!flag_syntax_only)
4544 targetm.asm_out.file_start ();
4546 #ifdef ASM_COMMENT_START
4547 if (flag_verbose_asm)
4549 /* Print the list of options in effect. */
4550 print_version (asm_out_file, ASM_COMMENT_START);
4551 print_switch_values (asm_out_file, 0, MAX_LINE,
4552 ASM_COMMENT_START, " ", "\n");
4553 /* Add a blank line here so it appears in assembler output but not
4555 fprintf (asm_out_file, "\n");
4561 /* Initialization of the front end environment, before command line
4562 options are parsed. Signal handlers, internationalization etc.
4563 ARGV0 is main's argv[0]. */
4565 general_init (const char *argv0)
4569 p = argv0 + strlen (argv0);
4570 while (p != argv0 && !IS_DIR_SEPARATOR (p[-1]))
4574 xmalloc_set_program_name (progname);
4578 gcc_init_libintl ();
4580 /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages. */
4582 signal (SIGSEGV, crash_signal);
4585 signal (SIGILL, crash_signal);
4588 signal (SIGBUS, crash_signal);
4591 signal (SIGABRT, crash_signal);
4593 #if defined SIGIOT && (!defined SIGABRT || SIGABRT != SIGIOT)
4594 signal (SIGIOT, crash_signal);
4597 signal (SIGFPE, crash_signal);
4600 /* Other host-specific signal setup. */
4601 (*host_hooks.extra_signals)();
4603 /* Initialize the diagnostics reporting machinery, so option parsing
4604 can give warnings and errors. */
4605 diagnostic_initialize (global_dc);
4607 /* Initialize the garbage-collector, string pools and tree type hash
4613 /* Initialize register usage now so switches may override. */
4616 /* Register the language-independent parameters. */
4617 add_params (lang_independent_params, LAST_PARAM);
4619 /* This must be done after add_params but before argument processing. */
4620 init_ggc_heuristics();
4623 /* Process the options that have been parsed. */
4625 process_options (void)
4627 /* Allow the front end to perform consistency checks and do further
4628 initialization based on the command line options. This hook also
4629 sets the original filename if appropriate (e.g. foo.i -> foo.c)
4630 so we can correctly initialize debug output. */
4631 no_backend = (*lang_hooks.post_options) (&main_input_filename);
4632 input_filename = main_input_filename;
4634 #ifdef OVERRIDE_OPTIONS
4635 /* Some machines may reject certain combinations of options. */
4639 /* Set aux_base_name if not already set. */
4642 else if (main_input_filename)
4644 char *name = xstrdup (lbasename (main_input_filename));
4646 strip_off_ending (name, strlen (name));
4647 aux_base_name = name;
4650 aux_base_name = "gccaux";
4652 /* Set up the align_*_log variables, defaulting them to 1 if they
4653 were still unset. */
4654 if (align_loops <= 0) align_loops = 1;
4655 if (align_loops_max_skip > align_loops || !align_loops)
4656 align_loops_max_skip = align_loops - 1;
4657 align_loops_log = floor_log2 (align_loops * 2 - 1);
4658 if (align_jumps <= 0) align_jumps = 1;
4659 if (align_jumps_max_skip > align_jumps || !align_jumps)
4660 align_jumps_max_skip = align_jumps - 1;
4661 align_jumps_log = floor_log2 (align_jumps * 2 - 1);
4662 if (align_labels <= 0) align_labels = 1;
4663 align_labels_log = floor_log2 (align_labels * 2 - 1);
4664 if (align_labels_max_skip > align_labels || !align_labels)
4665 align_labels_max_skip = align_labels - 1;
4666 if (align_functions <= 0) align_functions = 1;
4667 align_functions_log = floor_log2 (align_functions * 2 - 1);
4669 /* Unrolling all loops implies that standard loop unrolling must also
4671 if (flag_unroll_all_loops)
4672 flag_unroll_loops = 1;
4674 if (flag_unroll_loops)
4676 flag_old_unroll_loops = 0;
4677 flag_old_unroll_all_loops = 0;
4680 if (flag_old_unroll_all_loops)
4681 flag_old_unroll_loops = 1;
4683 /* Old loop unrolling requires that strength_reduction be on also. Silently
4684 turn on strength reduction here if it isn't already on. Also, the loop
4685 unrolling code assumes that cse will be run after loop, so that must
4686 be turned on also. */
4687 if (flag_old_unroll_loops)
4689 flag_strength_reduce = 1;
4690 flag_rerun_cse_after_loop = 1;
4692 if (flag_unroll_loops || flag_peel_loops)
4693 flag_rerun_cse_after_loop = 1;
4695 if (flag_non_call_exceptions)
4696 flag_asynchronous_unwind_tables = 1;
4697 if (flag_asynchronous_unwind_tables)
4698 flag_unwind_tables = 1;
4700 /* Disable unit-at-a-time mode for frontends not supporting callgraph
4702 if (flag_unit_at_a_time && ! lang_hooks.callgraph.expand_function)
4703 flag_unit_at_a_time = 0;
4705 /* Warn about options that are not supported on this machine. */
4706 #ifndef INSN_SCHEDULING
4707 if (flag_schedule_insns || flag_schedule_insns_after_reload)
4708 warning ("instruction scheduling not supported on this target machine");
4711 if (flag_delayed_branch)
4712 warning ("this target machine does not have delayed branches");
4715 user_label_prefix = USER_LABEL_PREFIX;
4716 if (flag_leading_underscore != -1)
4718 /* If the default prefix is more complicated than "" or "_",
4719 issue a warning and ignore this option. */
4720 if (user_label_prefix[0] == 0 ||
4721 (user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
4723 user_label_prefix = flag_leading_underscore ? "_" : "";
4726 warning ("-f%sleading-underscore not supported on this target machine",
4727 flag_leading_underscore ? "" : "no-");
4730 /* If we are in verbose mode, write out the version and maybe all the
4731 option flags in use. */
4734 print_version (stderr, "");
4736 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
4739 if (flag_syntax_only)
4741 write_symbols = NO_DEBUG;
4745 /* Now we know write_symbols, set up the debug hooks based on it.
4746 By default we do nothing for debug output. */
4747 #if defined(DBX_DEBUGGING_INFO)
4748 if (write_symbols == DBX_DEBUG)
4749 debug_hooks = &dbx_debug_hooks;
4751 #if defined(XCOFF_DEBUGGING_INFO)
4752 if (write_symbols == XCOFF_DEBUG)
4753 debug_hooks = &xcoff_debug_hooks;
4755 #ifdef SDB_DEBUGGING_INFO
4756 if (write_symbols == SDB_DEBUG)
4757 debug_hooks = &sdb_debug_hooks;
4759 #ifdef DWARF_DEBUGGING_INFO
4760 if (write_symbols == DWARF_DEBUG)
4761 debug_hooks = &dwarf_debug_hooks;
4763 #ifdef DWARF2_DEBUGGING_INFO
4764 if (write_symbols == DWARF2_DEBUG)
4765 debug_hooks = &dwarf2_debug_hooks;
4767 #ifdef VMS_DEBUGGING_INFO
4768 if (write_symbols == VMS_DEBUG || write_symbols == VMS_AND_DWARF2_DEBUG)
4769 debug_hooks = &vmsdbg_debug_hooks;
4772 /* If auxiliary info generation is desired, open the output file.
4773 This goes in the same directory as the source file--unlike
4774 all the other output files. */
4775 if (flag_gen_aux_info)
4777 aux_info_file = fopen (aux_info_file_name, "w");
4778 if (aux_info_file == 0)
4779 fatal_error ("can't open %s: %m", aux_info_file_name);
4782 if (! targetm.have_named_sections)
4784 if (flag_function_sections)
4786 warning ("-ffunction-sections not supported for this target");
4787 flag_function_sections = 0;
4789 if (flag_data_sections)
4791 warning ("-fdata-sections not supported for this target");
4792 flag_data_sections = 0;
4796 if (flag_function_sections && profile_flag)
4798 warning ("-ffunction-sections disabled; it makes profiling impossible");
4799 flag_function_sections = 0;
4802 #ifndef HAVE_prefetch
4803 if (flag_prefetch_loop_arrays)
4805 warning ("-fprefetch-loop-arrays not supported for this target");
4806 flag_prefetch_loop_arrays = 0;
4809 if (flag_prefetch_loop_arrays && !HAVE_prefetch)
4811 warning ("-fprefetch-loop-arrays not supported for this target (try -march switches)");
4812 flag_prefetch_loop_arrays = 0;
4816 /* This combination of options isn't handled for i386 targets and doesn't
4817 make much sense anyway, so don't allow it. */
4818 if (flag_prefetch_loop_arrays && optimize_size)
4820 warning ("-fprefetch-loop-arrays is not supported with -Os");
4821 flag_prefetch_loop_arrays = 0;
4824 #ifndef OBJECT_FORMAT_ELF
4825 if (flag_function_sections && write_symbols != NO_DEBUG)
4826 warning ("-ffunction-sections may affect debugging on some targets");
4829 /* The presence of IEEE signaling NaNs, implies all math can trap. */
4830 if (flag_signaling_nans)
4831 flag_trapping_math = 1;
4834 /* Initialize the compiler back end. */
4838 /* init_emit_once uses reg_raw_mode and therefore must be called
4839 after init_regs which initialized reg_raw_mode. */
4841 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
4842 || debug_info_level == DINFO_LEVEL_VERBOSE
4843 #ifdef VMS_DEBUGGING_INFO
4844 /* Enable line number info for traceback. */
4845 || debug_info_level > DINFO_LEVEL_NONE
4847 || flag_test_coverage
4848 || warn_notreached);
4849 init_fake_stack_mems ();
4853 init_function_once ();
4854 init_varasm_once ();
4856 /* The following initialization functions need to generate rtl, so
4857 provide a dummy function context for them. */
4858 init_dummy_function_start ();
4860 if (flag_caller_saves)
4861 init_caller_save ();
4862 expand_dummy_function_end ();
4865 /* Language-dependent initialization. Returns nonzero on success. */
4867 lang_dependent_init (const char *name)
4869 if (dump_base_name == 0)
4870 dump_base_name = name ? name : "gccdump";
4872 /* Other front-end initialization. */
4873 if ((*lang_hooks.init) () == 0)
4876 init_asm_output (name);
4878 /* These create various _DECL nodes, so need to be called after the
4879 front end is initialized. */
4883 /* The following initialization functions need to generate rtl, so
4884 provide a dummy function context for them. */
4885 init_dummy_function_start ();
4887 expand_dummy_function_end ();
4889 /* If dbx symbol table desired, initialize writing it and output the
4890 predefined types. */
4891 timevar_push (TV_SYMOUT);
4893 #ifdef DWARF2_UNWIND_INFO
4894 if (dwarf2out_do_frame ())
4895 dwarf2out_frame_init ();
4898 /* Now we have the correct original filename, we can initialize
4900 (*debug_hooks->init) (name);
4902 timevar_pop (TV_SYMOUT);
4907 /* Clean up: close opened files, etc. */
4912 /* Close the dump files. */
4913 if (flag_gen_aux_info)
4915 fclose (aux_info_file);
4917 unlink (aux_info_file_name);
4920 /* Close non-debugging input and output files. Take special care to note
4921 whether fclose returns an error, since the pages might still be on the
4922 buffer chain while the file is open. */
4926 if (ferror (asm_out_file) != 0)
4927 fatal_error ("error writing to %s: %m", asm_file_name);
4928 if (fclose (asm_out_file) != 0)
4929 fatal_error ("error closing %s: %m", asm_file_name);
4932 /* Do whatever is necessary to finish printing the graphs. */
4933 if (graph_dump_format != no_graph)
4937 for (i = 0; i < (int) DFI_MAX; ++i)
4938 if (dump_file[i].initialized && dump_file[i].graph_dump_p)
4943 sprintf (seq, DUMPFILE_FORMAT, i);
4944 suffix = concat (seq, dump_file[i].extension, NULL);
4945 finish_graph_dump_file (dump_base_name, suffix);
4952 ggc_print_statistics ();
4953 stringpool_statistics ();
4954 dump_tree_statistics ();
4957 /* Free up memory for the benefit of leak detectors. */
4960 /* Language-specific end of compilation actions. */
4961 (*lang_hooks.finish) ();
4964 /* Initialize the compiler, and compile the input file. */
4968 /* Initialize timing first. The C front ends read the main file in
4969 the post_options hook, and C++ does file timings. */
4970 if (time_report || !quiet_flag || flag_detailed_statistics)
4972 timevar_start (TV_TOTAL);
4976 /* Don't do any more if an error has already occurred. */
4979 /* Set up the back-end if requested. */
4983 /* Language-dependent initialization. Returns true on success. */
4984 if (lang_dependent_init (main_input_filename))
4990 /* Stop timing and print the times. */
4991 timevar_stop (TV_TOTAL);
4992 timevar_print (stderr);
4995 /* Entry point of cc1, cc1plus, jc1, f771, etc.
4996 Decode command args, then call compile_file.
4997 Exit code is FATAL_EXIT_CODE if can't open files or if there were
4998 any errors, or SUCCESS_EXIT_CODE if compilation succeeded.
5000 It is not safe to call this function more than once. */
5003 toplev_main (unsigned int argc, const char **argv)
5007 /* Initialization of GCC's environment, and diagnostics. */
5008 general_init (argv[0]);
5010 /* Parse the options and do minimal processing; basically just
5011 enough to default flags appropriately. */
5012 decode_options (argc, argv);
5016 /* Exit early if we can (e.g. -help). */
5017 if (!exit_after_options)
5020 if (errorcount || sorrycount)
5021 return (FATAL_EXIT_CODE);
5023 return (SUCCESS_EXIT_CODE);