1 /* Top level of GCC compilers (cc1, cc1plus, etc.)
2 Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
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>
50 #include "insn-attr.h"
51 #include "insn-config.h"
52 #include "insn-flags.h"
53 #include "hard-reg-set.h"
60 #include "basic-block.h"
67 #include "diagnostic.h"
70 #include "dwarf2asm.h"
71 #include "integrate.h"
75 #include "langhooks.h"
76 #include "cfglayout.h"
77 #include "tree-alias-common.h"
79 #include "hosthooks.h"
83 #include "value-prof.h"
84 #include "alloc-pool.h"
86 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
87 #include "dwarf2out.h"
90 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
94 #ifdef SDB_DEBUGGING_INFO
98 #ifdef XCOFF_DEBUGGING_INFO
99 #include "xcoffout.h" /* Needed for external data
100 declarations for e.g. AIX 4.x. */
103 static void general_init (const char *);
104 static void do_compile (void);
105 static void process_options (void);
106 static void backend_init (void);
107 static int lang_dependent_init (const char *);
108 static void init_asm_output (const char *);
109 static void finalize (void);
111 static void crash_signal (int) ATTRIBUTE_NORETURN;
112 static void setup_core_dumping (void);
113 static void compile_file (void);
115 static int print_single_switch (FILE *, int, int, const char *,
116 const char *, const char *,
117 const char *, const char *);
118 static void print_switch_values (FILE *, int, int, const char *,
119 const char *, const char *);
121 /* Nonzero to dump debug info whilst parsing (-dy option). */
122 static int set_yydebug;
124 /* True if we don't need a backend (e.g. preprocessing only). */
125 static bool no_backend;
127 /* Length of line when printing switch values. */
130 /* Name of program invoked, sans directories. */
132 const char *progname;
134 /* Copy of argument vector to toplev_main. */
135 static const char **save_argv;
137 /* Name of top-level original source file (what was input to cpp).
138 This comes from the #-command at the beginning of the actual input.
139 If there isn't any there, then this is the cc1 input file name. */
141 const char *main_input_filename;
143 /* Used to enable -fvar-tracking, -fweb and -frename-registers according
144 to optimize and default_debug_hooks in process_options (). */
145 #define AUTODETECT_FLAG_VAR_TRACKING 2
147 /* Current position in real source file. */
149 location_t input_location;
151 struct line_maps line_table;
153 /* Nonzero if it is unsafe to create any new pseudo registers. */
156 /* Stack of currently pending input files. */
158 struct file_stack *input_file_stack;
160 /* Incremented on each change to input_file_stack. */
161 int input_file_stack_tick;
163 /* Name to use as base of names for dump output files. */
165 const char *dump_base_name;
167 /* Name to use as a base for auxiliary output files. */
169 const char *aux_base_name;
171 /* Bit flags that specify the machine subtype we are compiling for.
172 Bits are tested using macros TARGET_... defined in the tm.h file
173 and set by `-m...' switches. Must be defined in rtlanal.c. */
175 extern int target_flags;
177 /* A mask of target_flags that includes bit X if X was set or cleared
178 on the command line. */
180 int target_flags_explicit;
182 /* Debug hooks - dependent upon command line options. */
184 const struct gcc_debug_hooks *debug_hooks;
186 /* Debug hooks - target default. */
188 static const struct gcc_debug_hooks *default_debug_hooks;
190 /* Other flags saying which kinds of debugging dump have been requested. */
192 int rtl_dump_and_exit;
193 int flag_print_asm_name;
194 enum graph_dump_types graph_dump_format;
196 /* Name for output file of assembly code, specified with -o. */
198 const char *asm_file_name;
200 /* Nonzero means do optimizations. -O.
201 Particular numeric values stand for particular amounts of optimization;
202 thus, -O2 stores 2 here. However, the optimizations beyond the basic
203 ones are not controlled directly by this variable. Instead, they are
204 controlled by individual `flag_...' variables that are defaulted
205 based on this variable. */
209 /* Nonzero means optimize for size. -Os.
210 The only valid values are zero and nonzero. When optimize_size is
211 nonzero, optimize defaults to 2, but certain individual code
212 bloating optimizations are disabled. */
214 int optimize_size = 0;
216 /* The FUNCTION_DECL for the function currently being compiled,
217 or 0 if between functions. */
218 tree current_function_decl;
220 /* Set to the FUNC_BEGIN label of the current function, or NULL_TREE
222 tree current_function_func_begin_label;
224 /* A DECL for the current file-scope context. When using IMA, this heads a
225 chain of FILE_DECLs; currently only C uses it. */
227 tree current_file_decl;
229 /* Nonzero if doing dwarf2 duplicate elimination. */
231 int flag_eliminate_dwarf2_dups = 0;
233 /* Nonzero if doing unused type elimination. */
235 int flag_eliminate_unused_debug_types = 1;
237 /* Nonzero means emit debugging information only for symbols which are used. */
238 int flag_debug_only_used_symbols = 0;
240 /* Nonzero if generating code to do profiling. */
242 int profile_flag = 0;
244 /* Nonzero if generating code to profile program flow graph arcs. */
246 int profile_arc_flag = 0;
248 /* Nonzero if value histograms should be measured. */
250 int flag_profile_values = 0;
252 /* Nonzero if value histograms should be used to optimize code. */
253 int flag_value_profile_transformations = 0;
255 /* Nonzero if generating info for gcov to calculate line test coverage. */
257 int flag_test_coverage = 0;
259 /* Nonzero indicates that branch taken probabilities should be calculated. */
261 int flag_branch_probabilities = 0;
263 /* Nonzero if basic blocks should be reordered. */
265 int flag_reorder_blocks = 0;
267 /* Nonzero if blocks should be partitioned into hot and cold sections in
268 addition to being reordered. */
270 int flag_reorder_blocks_and_partition = 0;
272 /* Nonzero if functions should be reordered. */
274 int flag_reorder_functions = 0;
276 /* Nonzero if registers should be renamed. When
277 flag_rename_registers == AUTODETECT_FLAG_VAR_TRACKING it will be set
278 according to optimize and default_debug_hooks in process_options (),
279 but we do not do this yet because it triggers aborts in flow.c. */
280 int flag_rename_registers = 0;
281 int flag_cprop_registers = 0;
283 /* Nonzero for -pedantic switch: warn about anything
284 that standard spec forbids. */
288 /* Temporarily suppress certain warnings.
289 This is set while reading code from a system header file. */
291 int in_system_header = 0;
293 /* Don't print functions as they are compiled. -quiet. */
297 /* Print times taken by the various passes. -ftime-report. */
301 /* Print memory still in use at end of compilation (which may have little
302 to do with peak memory consumption). -fmem-report. */
306 /* Nonzero means to collect statistics which might be expensive
307 and to print them when we are done. */
308 int flag_detailed_statistics = 0;
310 /* A random sequence of characters, unless overridden by user. */
311 const char *flag_random_seed;
313 /* A local time stamp derived from the time of compilation. It will be
314 zero if the system cannot provide a time. It will be -1u, if the
315 user has specified a particular random seed. */
320 /* Nonzero means `char' should be signed. */
322 int flag_signed_char;
324 /* Nonzero means give an enum type only as many bytes as it needs. A value
325 of 2 means it has not yet been initialized. */
327 int flag_short_enums;
329 /* Nonzero for -fcaller-saves: allocate values in regs that need to
330 be saved across function calls, if that produces overall better code.
331 Optional now, so people can test it. */
333 int flag_caller_saves = 0;
335 /* Nonzero if structures and unions should be returned in memory.
337 This should only be defined if compatibility with another compiler or
338 with an ABI is needed, because it results in slower code. */
340 #ifndef DEFAULT_PCC_STRUCT_RETURN
341 #define DEFAULT_PCC_STRUCT_RETURN 1
344 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
346 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
348 /* Nonzero for -fforce-mem: load memory value into a register
349 before arithmetic on it. This makes better cse but slower compilation. */
351 int flag_force_mem = 0;
353 /* Nonzero for -fforce-addr: load memory address into a register before
354 reference to memory. This makes better cse but slower compilation. */
356 int flag_force_addr = 0;
358 /* Nonzero for -fdefer-pop: don't pop args after each function call;
359 instead save them up to pop many calls' args with one insns. */
361 int flag_defer_pop = 0;
363 /* Nonzero for -ffloat-store: don't allocate floats and doubles
364 in extended-precision registers. */
366 int flag_float_store = 0;
368 /* Nonzero for -fcse-follow-jumps:
369 have cse follow jumps to do a more extensive job. */
371 int flag_cse_follow_jumps;
373 /* Nonzero for -fcse-skip-blocks:
374 have cse follow a branch around a block. */
375 int flag_cse_skip_blocks;
377 /* Nonzero for -fexpensive-optimizations:
378 perform miscellaneous relatively-expensive optimizations. */
379 int flag_expensive_optimizations;
381 /* Nonzero for -fthread-jumps:
382 have jump optimize output of loop. */
384 int flag_thread_jumps;
386 /* Nonzero enables strength-reduction in loop.c. */
388 int flag_strength_reduce = 0;
390 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
391 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
392 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
395 int flag_old_unroll_loops;
397 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
398 This is generally not a win. */
400 int flag_old_unroll_all_loops;
402 /* Enables unrolling of simple loops in loop-unroll.c. */
403 int flag_unroll_loops;
405 /* Enables unrolling of all loops in loop-unroll.c. */
406 int flag_unroll_all_loops;
408 /* Nonzero enables loop peeling. */
411 /* Nonzero enables loop unswitching. */
412 int flag_unswitch_loops;
414 /* Nonzero enables prefetch optimizations for arrays in loops. */
416 int flag_prefetch_loop_arrays;
418 /* Nonzero forces all invariant computations in loops to be moved
421 int flag_move_all_movables = 0;
423 /* Nonzero forces all general induction variables in loops to be
426 int flag_reduce_all_givs = 0;
428 /* Nonzero to perform full register move optimization passes. This is the
431 int flag_regmove = 0;
433 /* Nonzero means don't put addresses of constant functions in registers.
434 Used for compiling the Unix kernel, where strange substitutions are
435 done on the assembly output. */
437 int flag_no_function_cse = 0;
439 /* Nonzero for -fomit-frame-pointer:
440 don't make a frame pointer in simple functions that don't require one. */
442 int flag_omit_frame_pointer = 0;
444 /* Nonzero means place each function into its own section on those platforms
445 which support arbitrary section names and unlimited numbers of sections. */
447 int flag_function_sections = 0;
449 /* ... and similar for data. */
451 int flag_data_sections = 0;
453 /* Nonzero to inhibit use of define_optimization peephole opts. */
455 int flag_no_peephole = 0;
457 /* Nonzero allows GCC to optimize sibling and tail recursive calls. */
459 int flag_optimize_sibling_calls = 0;
461 /* Nonzero means the front end generally wants `errno' maintained by math
462 operations, like built-in SQRT. */
464 int flag_errno_math = 1;
466 /* Nonzero means that unsafe floating-point math optimizations are allowed
467 for the sake of speed. IEEE compliance is not guaranteed, and operations
468 are allowed to assume that their arguments and results are "normal"
469 (e.g., nonnegative for SQRT). */
471 int flag_unsafe_math_optimizations = 0;
473 /* Nonzero means that no NaNs or +-Infs are expected. */
475 int flag_finite_math_only = 0;
477 /* Zero means that floating-point math operations cannot generate a
478 (user-visible) trap. This is the case, for example, in nonstop
479 IEEE 754 arithmetic. Trapping conditions include division by zero,
480 overflow, underflow, invalid and inexact, but does not include
481 operations on signaling NaNs (see below). */
483 int flag_trapping_math = 1;
485 /* Nonzero means disable transformations that assume default floating
486 point rounding behavior. */
488 int flag_rounding_math = 0;
490 /* Nonzero means disable transformations observable by signaling NaNs.
491 This option implies that any operation on an IEEE signaling NaN can
492 generate a (user-visible) trap. */
494 int flag_signaling_nans = 0;
496 /* 0 means straightforward implementation of complex divide acceptable.
497 1 means wide ranges of inputs must work for complex divide.
498 2 means C99-like requirements for complex divide (not yet implemented). */
500 int flag_complex_divide_method = 0;
502 /* Nonzero means just do syntax checking; don't output anything. */
504 int flag_syntax_only = 0;
506 /* Nonzero means performs web construction pass. When flag_web ==
507 AUTODETECT_FLAG_VAR_TRACKING it will be set according to optimize
508 and default_debug_hooks in process_options (). */
510 int flag_web = AUTODETECT_FLAG_VAR_TRACKING;
512 /* Nonzero means perform loop optimizer. */
514 int flag_loop_optimize;
516 /* Nonzero means perform crossjumping. */
518 int flag_crossjumping;
520 /* Nonzero means perform if conversion. */
522 int flag_if_conversion;
524 /* Nonzero means perform if conversion after reload. */
526 int flag_if_conversion2;
528 /* Nonzero means to use global dataflow analysis to eliminate
529 useless null pointer tests. */
531 int flag_delete_null_pointer_checks;
533 /* Nonzero means perform global CSE. */
537 /* Nonzero means to do the enhanced load motion during gcse, which trys
538 to hoist loads by not killing them when a store to the same location
541 int flag_gcse_lm = 1;
543 /* Nonzero means to perform store motion after gcse, which will try to
544 move stores closer to the exit block. Its not very effective without
547 int flag_gcse_sm = 1;
549 /* Nonzero if we want to perform redundant load after store elimination
552 int flag_gcse_las = 1;
554 /* Nonzero means perform global cse after register allocation. */
555 int flag_gcse_after_reload = 0;
557 /* Perform target register optimization before prologue / epilogue
560 int flag_branch_target_load_optimize = 0;
562 /* Perform target register optimization after prologue / epilogue
563 threading and jump2. */
565 int flag_branch_target_load_optimize2 = 0;
567 /* For the bt-load pass, nonzero means don't re-use branch target registers
568 in any basic block. */
570 int flag_btr_bb_exclusive;
572 /* Nonzero means to rerun cse after loop optimization. This increases
573 compilation time about 20% and picks up a few more common expressions. */
575 int flag_rerun_cse_after_loop;
577 /* Nonzero means to run loop optimizations twice. */
579 int flag_rerun_loop_opt;
581 /* Nonzero for -finline-functions: ok to inline functions that look like
582 good inline candidates. */
584 int flag_inline_functions;
586 /* Nonzero for -fkeep-inline-functions: even if we make a function
587 go inline everywhere, keep its definition around for debugging
590 int flag_keep_inline_functions;
592 /* Nonzero means that functions will not be inlined. */
594 int flag_no_inline = 2;
596 /* Nonzero means that we don't want inlining by virtue of -fno-inline,
597 not just because the tree inliner turned us off. */
599 int flag_really_no_inline = 2;
601 /* Nonzero means that we should emit static const variables
602 regardless of whether or not optimization is turned on. */
604 int flag_keep_static_consts = 1;
606 /* Nonzero means we should be saving declaration info into a .X file. */
608 int flag_gen_aux_info = 0;
610 /* Specified name of aux-info file. */
612 const char *aux_info_file_name;
614 /* Nonzero means make the text shared if supported. */
616 int flag_shared_data;
618 /* Nonzero means schedule into delayed branch slots if supported. */
620 int flag_delayed_branch;
622 /* Nonzero if we are compiling pure (sharable) code.
623 Value is 1 if we are doing "small" pic; value is 2 if we're doing
628 /* Nonzero if we are compiling position independent code for executable.
629 The value is 1 if we are doing "small" pic; value is 2 if we're doing
634 /* Nonzero if we are compiling code for a shared library, zero for
639 /* Set to the default thread-local storage (tls) model to use. */
641 enum tls_model flag_tls_default = TLS_MODEL_GLOBAL_DYNAMIC;
643 /* Nonzero means generate extra code for exception handling and enable
644 exception handling. */
648 /* Nonzero means generate frame unwind info table when supported. */
650 int flag_unwind_tables = 0;
652 /* Nonzero means generate frame unwind info table exact at each insn
655 int flag_asynchronous_unwind_tables = 0;
657 /* Nonzero means don't place uninitialized global data in common storage
662 /* Nonzero means change certain warnings into errors.
663 Usually these are warnings about failure to conform to some standard. */
665 int flag_pedantic_errors = 0;
667 /* flag_schedule_insns means schedule insns within basic blocks (before
669 flag_schedule_insns_after_reload means schedule insns after
672 int flag_schedule_insns = 0;
673 int flag_schedule_insns_after_reload = 0;
675 /* When flag_schedule_insns_after_reload is set, use EBB scheduler. */
676 int flag_sched2_use_superblocks = 0;
678 /* When flag_schedule_insns_after_reload is set, construct traces and EBB
680 int flag_sched2_use_traces = 0;
682 /* The following flags have effect only for scheduling before register
685 flag_schedule_interblock means schedule insns across basic blocks.
686 flag_schedule_speculative means allow speculative motion of non-load insns.
687 flag_schedule_speculative_load means allow speculative motion of some
689 flag_schedule_speculative_load_dangerous allows speculative motion of more
692 int flag_schedule_interblock = 1;
693 int flag_schedule_speculative = 1;
694 int flag_schedule_speculative_load = 0;
695 int flag_schedule_speculative_load_dangerous = 0;
697 /* The following flags have an effect during scheduling after register
700 flag_sched_stalled_insns means that insns can be moved prematurely from the queue
701 of stalled insns into the ready list.
703 flag_sched_stalled_insns_dep controls how many insn groups will be examined
704 for a dependency on a stalled insn that is candidate for premature removal
705 from the queue of stalled insns into the ready list (has an effect only if
706 the flag 'sched_stalled_insns' is set). */
708 int flag_sched_stalled_insns = 0;
709 int flag_sched_stalled_insns_dep = 1;
711 /* The following flag controls the module scheduling activation. */
712 int flag_modulo_sched = 0;
714 int flag_single_precision_constant;
716 /* flag_branch_on_count_reg means try to replace add-1,compare,branch tupple
717 by a cheaper branch on a count register. */
718 int flag_branch_on_count_reg = 1;
720 /* -finhibit-size-directive inhibits output of .size for ELF.
721 This is used only for compiling crtstuff.c,
722 and it may be extended to other effects
723 needed for crtstuff.c on other systems. */
724 int flag_inhibit_size_directive = 0;
726 /* -fverbose-asm causes extra commentary information to be produced in
727 the generated assembly code (to make it more readable). This option
728 is generally only of use to those who actually need to read the
729 generated assembly code (perhaps while debugging the compiler itself).
730 -fno-verbose-asm, the default, causes the extra information
731 to be omitted and is useful when comparing two assembler files. */
733 int flag_verbose_asm = 0;
735 /* -dA causes debug commentary information to be produced in
736 the generated assembly code (to make it more readable). This option
737 is generally only of use to those who actually need to read the
738 generated assembly code (perhaps while debugging the compiler itself).
739 Currently, this switch is only used by dwarfout.c; however, it is intended
740 to be a catchall for printing debug information in the assembler file. */
742 int flag_debug_asm = 0;
744 /* -dP causes the rtl to be emitted as a comment in assembly. */
746 int flag_dump_rtl_in_asm = 0;
748 /* Nonzero means put zero initialized data in the bss section. */
749 int flag_zero_initialized_in_bss = 1;
751 /* Tag all structures with __attribute__(packed). */
752 int flag_pack_struct = 0;
754 /* Emit code to check for stack overflow; also may cause large objects
755 to be allocated dynamically. */
756 int flag_stack_check;
758 /* When non-NULL, indicates that whenever space is allocated on the
759 stack, the resulting stack pointer must not pass this
760 address---that is, for stacks that grow downward, the stack pointer
761 must always be greater than or equal to this address; for stacks
762 that grow upward, the stack pointer must be less than this address.
763 At present, the rtx may be either a REG or a SYMBOL_REF, although
764 the support provided depends on the backend. */
767 /* 0 if pointer arguments may alias each other. True in C.
768 1 if pointer arguments may not alias each other but may alias
770 2 if pointer arguments may not alias each other and may not
771 alias global variables. True in Fortran.
772 This defaults to 0 for C. */
773 int flag_argument_noalias = 0;
775 /* Nonzero if we should do (language-dependent) alias analysis.
776 Typically, this analysis will assume that expressions of certain
777 types do not alias expressions of certain other types. Only used
778 if alias analysis (in general) is enabled. */
779 int flag_strict_aliasing = 0;
781 /* Instrument functions with calls at entry and exit, for profiling. */
782 int flag_instrument_function_entry_exit = 0;
784 /* Nonzero means ignore `#ident' directives. 0 means handle them.
785 On SVR4 targets, it also controls whether or not to emit a
786 string identifying the compiler. */
788 int flag_no_ident = 0;
790 /* This will perform a peephole pass before sched2. */
791 int flag_peephole2 = 0;
793 /* This will try to guess branch probabilities. */
794 int flag_guess_branch_prob = 0;
796 /* -fcheck-bounds causes gcc to generate array bounds checks.
797 For C, C++, ObjC: defaults to off.
798 For Java: defaults to on.
799 For Fortran: defaults to off. */
800 int flag_bounds_check = 0;
802 /* Mudflap bounds-checking transform. */
803 int flag_mudflap = 0;
804 int flag_mudflap_threads = 0;
805 int flag_mudflap_ignore_reads = 0;
807 /* This will attempt to merge constant section constants, if 1 only
808 string constants and constants from constant pool, if 2 also constant
810 int flag_merge_constants = 1;
812 /* If one, renumber instruction UIDs to reduce the number of
813 unused UIDs if there are a lot of instructions. If greater than
814 one, unconditionally renumber instruction UIDs. */
815 int flag_renumber_insns = 1;
817 /* If nonzero, use the graph coloring register allocator. */
818 int flag_new_regalloc = 0;
820 /* If nonzero, use tree-based instead of rtl-based profiling. */
821 int flag_tree_based_profiling = 0;
823 /* Enable SSA-GVN on trees. */
824 int flag_tree_gvn = 0;
826 /* Enable the SSA-PRE tree optimization. */
827 int flag_tree_pre = 0;
829 /* Enable points-to analysis on trees. */
830 enum pta_type flag_tree_points_to = PTA_NONE;
832 /* Enable SSA-CCP on trees. */
833 int flag_tree_ccp = 0;
835 /* Enable SSA-DCE on trees. */
836 int flag_tree_dce = 0;
838 /* Enable loop header copying on tree-ssa. */
839 int flag_tree_ch = 0;
841 /* Enable scalar replacement of aggregates. */
842 int flag_tree_sra = 0;
844 /* Enable SSA->normal pass memory location coalescing. */
845 int flag_tree_combine_temps = 0;
847 /* Enable SSA->normal pass expression replacement. */
848 int flag_tree_ter = 0;
850 /* Enable SSA->normal live range splitting. */
851 int flag_tree_live_range_split = 0;
853 /* Enable dominator optimizations. */
854 int flag_tree_dom = 0;
856 /* Enable copy rename optimization. */
857 int flag_tree_copyrename = 0;
859 /* Enable dead store elimination. */
860 int flag_tree_dse = 0;
862 /* Nonzero if we perform superblock formation. */
865 /* Nonzero if we perform whole unit at a time compilation. */
867 int flag_unit_at_a_time = 0;
869 /* Nonzero if we should track variables. When
870 flag_var_tracking == AUTODETECT_FLAG_VAR_TRACKING it will be set according
871 to optimize, debug_info_level and debug_hooks in process_options (). */
872 int flag_var_tracking = AUTODETECT_FLAG_VAR_TRACKING;
874 /* Values of the -falign-* flags: how much to align labels in code.
875 0 means `use default', 1 means `don't align'.
876 For each variable, there is an _log variant which is the power
877 of two not less than the variable, for .align output. */
881 int align_loops_max_skip;
884 int align_jumps_max_skip;
886 int align_labels_log;
887 int align_labels_max_skip;
889 int align_functions_log;
891 /* Like align_functions_log above, but used by front-ends to force the
892 minimum function alignment. Zero means no alignment is forced. */
893 int force_align_functions_log;
897 const char *const string;
901 lang_independent_options;
903 /* Nonzero if signed arithmetic overflow should trap. */
906 /* Nonzero if signed arithmetic overflow should wrap around. */
909 /* Nonzero if subexpressions must be evaluated from left-to-right. */
910 int flag_evaluation_order = 0;
912 /* Add or remove a leading underscore from user symbols. */
913 int flag_leading_underscore = -1;
915 /* The version of the C++ ABI in use. The following values are
918 0: The version of the ABI believed most conformant with the
919 C++ ABI specification. This ABI may change as bugs are
920 discovered and fixed. Therefore, 0 will not necessarily
921 indicate the same ABI in different versions of G++.
923 1: The version of the ABI first used in G++ 3.2.
925 2: The version of the ABI first used in G++ 3.4.
927 Additional positive integers will be assigned as new versions of
928 the ABI become the default version of the ABI. */
930 int flag_abi_version = 2;
932 /* The user symbol prefix after having resolved same. */
933 const char *user_label_prefix;
935 static const param_info lang_independent_params[] = {
936 #define DEFPARAM(ENUM, OPTION, HELP, DEFAULT) \
937 { OPTION, DEFAULT, HELP },
938 #include "params.def"
943 /* Table of language-independent -f options.
944 STRING is the option name. VARIABLE is the address of the variable.
945 ON_VALUE is the value to store in VARIABLE
946 if `-fSTRING' is seen as an option.
947 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
949 static const lang_independent_options f_options[] =
951 {"eliminate-dwarf2-dups", &flag_eliminate_dwarf2_dups, 1 },
952 {"eliminate-unused-debug-symbols", &flag_debug_only_used_symbols, 1 },
953 {"eliminate-unused-debug-types", &flag_eliminate_unused_debug_types, 1 },
954 {"float-store", &flag_float_store, 1 },
955 {"defer-pop", &flag_defer_pop, 1 },
956 {"omit-frame-pointer", &flag_omit_frame_pointer, 1 },
957 {"optimize-sibling-calls", &flag_optimize_sibling_calls, 1 },
958 {"tracer", &flag_tracer, 1 },
959 {"unit-at-a-time", &flag_unit_at_a_time, 1 },
960 {"cse-follow-jumps", &flag_cse_follow_jumps, 1 },
961 {"cse-skip-blocks", &flag_cse_skip_blocks, 1 },
962 {"expensive-optimizations", &flag_expensive_optimizations, 1 },
963 {"thread-jumps", &flag_thread_jumps, 1 },
964 {"strength-reduce", &flag_strength_reduce, 1 },
965 {"unroll-loops", &flag_unroll_loops, 1 },
966 {"unroll-all-loops", &flag_unroll_all_loops, 1 },
967 {"old-unroll-loops", &flag_old_unroll_loops, 1 },
968 {"old-unroll-all-loops", &flag_old_unroll_all_loops, 1 },
969 {"peel-loops", &flag_peel_loops, 1 },
970 {"unswitch-loops", &flag_unswitch_loops, 1 },
971 {"prefetch-loop-arrays", &flag_prefetch_loop_arrays, 1 },
972 {"move-all-movables", &flag_move_all_movables, 1 },
973 {"reduce-all-givs", &flag_reduce_all_givs, 1 },
974 {"peephole", &flag_no_peephole, 0 },
975 {"force-mem", &flag_force_mem, 1 },
976 {"force-addr", &flag_force_addr, 1 },
977 {"function-cse", &flag_no_function_cse, 0 },
978 {"inline-functions", &flag_inline_functions, 1 },
979 {"keep-inline-functions", &flag_keep_inline_functions, 1 },
980 {"inline", &flag_no_inline, 0 },
981 {"keep-static-consts", &flag_keep_static_consts, 1 },
982 {"syntax-only", &flag_syntax_only, 1 },
983 {"shared-data", &flag_shared_data, 1 },
984 {"caller-saves", &flag_caller_saves, 1 },
985 {"pcc-struct-return", &flag_pcc_struct_return, 1 },
986 {"reg-struct-return", &flag_pcc_struct_return, 0 },
987 {"delayed-branch", &flag_delayed_branch, 1 },
988 {"web", &flag_web, 1},
989 {"gcse", &flag_gcse, 1 },
990 {"gcse-lm", &flag_gcse_lm, 1 },
991 {"gcse-sm", &flag_gcse_sm, 1 },
992 {"gcse-las", &flag_gcse_las, 1 },
993 {"gcse-after-reload", &flag_gcse_after_reload, 1},
994 {"branch-target-load-optimize", &flag_branch_target_load_optimize, 1 },
995 {"branch-target-load-optimize2", &flag_branch_target_load_optimize2, 1 },
996 {"btr-bb-exclusive", &flag_btr_bb_exclusive, 1 },
997 {"loop-optimize", &flag_loop_optimize, 1 },
998 {"crossjumping", &flag_crossjumping, 1 },
999 {"if-conversion", &flag_if_conversion, 1 },
1000 {"if-conversion2", &flag_if_conversion2, 1 },
1001 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1 },
1002 {"rerun-loop-opt", &flag_rerun_loop_opt, 1 },
1003 {"delete-null-pointer-checks", &flag_delete_null_pointer_checks, 1 },
1004 {"schedule-insns", &flag_schedule_insns, 1 },
1005 {"schedule-insns2", &flag_schedule_insns_after_reload, 1 },
1006 {"sched-interblock",&flag_schedule_interblock, 1 },
1007 {"sched-spec",&flag_schedule_speculative, 1 },
1008 {"sched-spec-load",&flag_schedule_speculative_load, 1 },
1009 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1 },
1010 {"sched-stalled-insns", &flag_sched_stalled_insns, 0 },
1011 {"sched-stalled-insns-dep", &flag_sched_stalled_insns_dep, 1 },
1012 {"sched2-use-superblocks", &flag_sched2_use_superblocks, 1 },
1013 {"sched2-use-traces", &flag_sched2_use_traces, 1 },
1014 {"modulo-sched", &flag_modulo_sched, 1 },
1015 {"branch-count-reg",&flag_branch_on_count_reg, 1 },
1016 {"pic", &flag_pic, 1 },
1017 {"PIC", &flag_pic, 2 },
1018 {"pie", &flag_pie, 1 },
1019 {"PIE", &flag_pie, 2 },
1020 {"exceptions", &flag_exceptions, 1 },
1021 {"unwind-tables", &flag_unwind_tables, 1 },
1022 {"asynchronous-unwind-tables", &flag_asynchronous_unwind_tables, 1 },
1023 {"non-call-exceptions", &flag_non_call_exceptions, 1 },
1024 {"profile-arcs", &profile_arc_flag, 1 },
1025 {"profile-values", &flag_profile_values, 1 },
1026 {"vpt", &flag_value_profile_transformations, 1 },
1027 {"test-coverage", &flag_test_coverage, 1 },
1028 {"branch-probabilities", &flag_branch_probabilities, 1 },
1029 {"profile", &profile_flag, 1 },
1030 {"tree-based-profiling", &flag_tree_based_profiling, 1 },
1031 {"reorder-blocks", &flag_reorder_blocks, 1 },
1032 {"reorder-blocks-and-partition", &flag_reorder_blocks_and_partition, 1},
1033 {"reorder-functions", &flag_reorder_functions, 1 },
1034 {"rename-registers", &flag_rename_registers, 1 },
1035 {"cprop-registers", &flag_cprop_registers, 1 },
1036 {"common", &flag_no_common, 0 },
1037 {"inhibit-size-directive", &flag_inhibit_size_directive, 1 },
1038 {"function-sections", &flag_function_sections, 1 },
1039 {"data-sections", &flag_data_sections, 1 },
1040 {"verbose-asm", &flag_verbose_asm, 1 },
1041 {"regmove", &flag_regmove, 1 },
1042 {"optimize-register-move", &flag_regmove, 1 },
1043 {"pack-struct", &flag_pack_struct, 1 },
1044 {"stack-check", &flag_stack_check, 1 },
1045 {"argument-alias", &flag_argument_noalias, 0 },
1046 {"argument-noalias", &flag_argument_noalias, 1 },
1047 {"argument-noalias-global", &flag_argument_noalias, 2 },
1048 {"strict-aliasing", &flag_strict_aliasing, 1 },
1049 {"align-loops", &align_loops, 0 },
1050 {"align-jumps", &align_jumps, 0 },
1051 {"align-labels", &align_labels, 0 },
1052 {"align-functions", &align_functions, 0 },
1053 {"merge-constants", &flag_merge_constants, 1 },
1054 {"merge-all-constants", &flag_merge_constants, 2 },
1055 {"dump-unnumbered", &flag_dump_unnumbered, 1 },
1056 {"instrument-functions", &flag_instrument_function_entry_exit, 1 },
1057 {"zero-initialized-in-bss", &flag_zero_initialized_in_bss, 1 },
1058 {"leading-underscore", &flag_leading_underscore, 1 },
1059 {"ident", &flag_no_ident, 0 },
1060 { "peephole2", &flag_peephole2, 1 },
1061 {"finite-math-only", &flag_finite_math_only, 1 },
1062 { "guess-branch-probability", &flag_guess_branch_prob, 1 },
1063 {"math-errno", &flag_errno_math, 1 },
1064 {"trapping-math", &flag_trapping_math, 1 },
1065 {"rounding-math", &flag_rounding_math, 1 },
1066 {"unsafe-math-optimizations", &flag_unsafe_math_optimizations, 1 },
1067 {"signaling-nans", &flag_signaling_nans, 1 },
1068 {"bounds-check", &flag_bounds_check, 1 },
1069 {"single-precision-constant", &flag_single_precision_constant, 1 },
1070 {"time-report", &time_report, 1 },
1071 {"mem-report", &mem_report, 1 },
1072 { "trapv", &flag_trapv, 1 },
1073 { "wrapv", &flag_wrapv, 1 },
1074 { "new-ra", &flag_new_regalloc, 1 },
1075 { "var-tracking", &flag_var_tracking, 1},
1076 { "tree-gvn", &flag_tree_gvn, 1 },
1077 { "tree-pre", &flag_tree_pre, 1 },
1078 { "tree-ccp", &flag_tree_ccp, 1 },
1079 { "tree-dce", &flag_tree_dce, 1 },
1080 { "tree-dominator-opts", &flag_tree_dom, 1 },
1081 { "tree-copyrename", &flag_tree_copyrename, 1 },
1082 { "tree-dse", &flag_tree_dse, 1 },
1083 { "tree-combine-temps", &flag_tree_combine_temps, 1 },
1084 { "tree-ter", &flag_tree_ter, 1 },
1085 { "tree-lrs", &flag_tree_live_range_split, 1 },
1086 { "tree-ch", &flag_tree_ch, 1 }
1089 /* Here is a table, controlled by the tm.h file, listing each -m switch
1090 and which bits in `target_switches' it should set or clear.
1091 If VALUE is positive, it is bits to set.
1092 If VALUE is negative, -VALUE is bits to clear.
1093 (The sign bit is not used so there is no confusion.) */
1097 const char *const name;
1099 const char *const description;
1101 target_switches[] = TARGET_SWITCHES;
1103 /* This table is similar, but allows the switch to have a value. */
1105 #ifdef TARGET_OPTIONS
1108 const char *const prefix;
1109 const char **const variable;
1110 const char *const description;
1111 const char *const value;
1113 target_options[] = TARGET_OPTIONS;
1116 /* Nonzero means warn about function definitions that default the return type
1117 or that use a null return and have a return-type other than void. */
1119 int warn_return_type;
1121 /* Output files for assembler code (real compiler output)
1122 and debugging dumps. */
1125 FILE *aux_info_file;
1126 FILE *dump_file = NULL;
1127 FILE *cgraph_dump_file = NULL;
1129 /* The current working directory of a translation. It's generally the
1130 directory from which compilation was initiated, but a preprocessed
1131 file may specify the original directory in which it was
1134 static const char *src_pwd;
1136 /* Initialize src_pwd with the given string, and return true. If it
1137 was already initialized, return false. As a special case, it may
1138 be called with a NULL argument to test whether src_pwd has NOT been
1142 set_src_pwd (const char *pwd)
1146 if (strcmp (src_pwd, pwd) == 0)
1152 src_pwd = xstrdup (pwd);
1156 /* Return the directory from which the translation unit was initiated,
1157 in case set_src_pwd() was not called before to assign it a
1164 src_pwd = getpwd ();
1169 /* Called when the start of a function definition is parsed,
1170 this function prints on stderr the name of the function. */
1172 announce_function (tree decl)
1176 if (rtl_dump_and_exit)
1177 verbatim ("%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
1179 verbatim (" %s", lang_hooks.decl_printable_name (decl, 2));
1181 pp_needs_newline (global_dc->printer) = true;
1182 diagnostic_set_last_function (global_dc);
1186 /* Set up a default flag_random_seed and local_tick, unless the user
1187 already specified one. */
1192 if (!flag_random_seed)
1194 unsigned HOST_WIDE_INT value;
1195 static char random_seed[HOST_BITS_PER_WIDE_INT / 4 + 3];
1197 /* Get some more or less random data. */
1198 #ifdef HAVE_GETTIMEOFDAY
1202 gettimeofday (&tv, NULL);
1203 local_tick = tv.tv_sec * 1000 + tv.tv_usec / 1000;
1207 time_t now = time (NULL);
1209 if (now != (time_t)-1)
1210 local_tick = (unsigned) now;
1213 value = local_tick ^ getpid ();
1215 sprintf (random_seed, HOST_WIDE_INT_PRINT_HEX, value);
1216 flag_random_seed = random_seed;
1218 else if (!local_tick)
1223 /* Decode the string P as an integral parameter.
1224 If the string is indeed an integer return its numeric value else
1225 issue an Invalid Option error for the option PNAME and return DEFVAL.
1226 If PNAME is zero just return DEFVAL, do not call error. */
1229 read_integral_parameter (const char *p, const char *pname, const int defval)
1231 const char *endp = p;
1235 if (ISDIGIT (*endp))
1244 error ("invalid option argument `%s'", pname);
1251 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1252 If X is 0, return -1.
1254 This should be used via the floor_log2 macro. */
1257 floor_log2_wide (unsigned HOST_WIDE_INT x)
1262 if (sizeof (HOST_WIDE_INT)*8 > 64)
1263 if (x >= (unsigned HOST_WIDE_INT)(1 << (t+64)))
1265 if (sizeof (HOST_WIDE_INT)*8 > 32)
1266 if (x >= (unsigned HOST_WIDE_INT)(1 << (t+32)))
1268 if (x >= (unsigned HOST_WIDE_INT)(1 << (t+16)))
1270 if (x >= (unsigned HOST_WIDE_INT)(1 << (t+8)))
1272 if (x >= (unsigned HOST_WIDE_INT)(1 << (t+4)))
1274 if (x >= (unsigned HOST_WIDE_INT)(1 << (t+2)))
1276 if (x >= (unsigned HOST_WIDE_INT)(1 << (t+1)))
1281 /* Return the logarithm of X, base 2, considering X unsigned,
1282 if X is a power of 2. Otherwise, returns -1.
1284 This should be used via the `exact_log2' macro. */
1287 exact_log2_wide (unsigned HOST_WIDE_INT x)
1289 /* Test for 0 or a power of 2. */
1290 if (x == 0 || x != (x & -x))
1292 return floor_log2_wide (x);
1295 /* Handler for fatal signals, such as SIGSEGV. These are transformed
1296 into ICE messages, which is much more user friendly. In case the
1297 error printer crashes, reset the signal to prevent infinite recursion. */
1300 crash_signal (int signo)
1302 signal (signo, SIG_DFL);
1303 internal_error ("%s", strsignal (signo));
1306 /* Arrange to dump core on error. (The regular error message is still
1307 printed first, except in the case of abort().) */
1310 setup_core_dumping (void)
1313 signal (SIGABRT, SIG_DFL);
1315 #if defined(HAVE_SETRLIMIT)
1318 if (getrlimit (RLIMIT_CORE, &rlim) != 0)
1319 fatal_error ("getting core file size maximum limit: %m");
1320 rlim.rlim_cur = rlim.rlim_max;
1321 if (setrlimit (RLIMIT_CORE, &rlim) != 0)
1322 fatal_error ("setting core file size limit to maximum: %m");
1325 diagnostic_abort_on_error (global_dc);
1329 /* Strip off a legitimate source ending from the input string NAME of
1330 length LEN. Rather than having to know the names used by all of
1331 our front ends, we strip off an ending of a period followed by
1332 up to five characters. (Java uses ".class".) */
1335 strip_off_ending (char *name, int len)
1338 for (i = 2; i < 6 && len > i; i++)
1340 if (name[len - i] == '.')
1342 name[len - i] = '\0';
1348 /* Output a quoted string. */
1351 output_quoted_string (FILE *asm_file, const char *string)
1353 #ifdef OUTPUT_QUOTED_STRING
1354 OUTPUT_QUOTED_STRING (asm_file, string);
1358 putc ('\"', asm_file);
1359 while ((c = *string++) != 0)
1363 if (c == '\"' || c == '\\')
1364 putc ('\\', asm_file);
1368 fprintf (asm_file, "\\%03o", (unsigned char) c);
1370 putc ('\"', asm_file);
1374 /* Output a file name in the form wanted by System V. */
1377 output_file_directive (FILE *asm_file, const char *input_name)
1382 if (input_name == NULL)
1383 input_name = "<stdin>";
1385 len = strlen (input_name);
1386 na = input_name + len;
1388 /* NA gets INPUT_NAME sans directory names. */
1389 while (na > input_name)
1391 if (IS_DIR_SEPARATOR (na[-1]))
1396 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1397 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1399 fprintf (asm_file, "\t.file\t");
1400 output_quoted_string (asm_file, na);
1401 fputc ('\n', asm_file);
1405 /* Do any final processing required for the declarations in VEC, of
1406 which there are LEN. We write out inline functions and variables
1407 that have been deferred until this point, but which are required.
1408 Returns nonzero if anything was put out. */
1411 wrapup_global_declarations (tree *vec, int len)
1416 int output_something = 0;
1418 for (i = 0; i < len; i++)
1422 /* We're not deferring this any longer. Assignment is
1423 conditional to avoid needlessly dirtying PCH pages. */
1424 if (DECL_DEFER_OUTPUT (decl) != 0)
1425 DECL_DEFER_OUTPUT (decl) = 0;
1427 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0)
1428 lang_hooks.finish_incomplete_decl (decl);
1431 /* Now emit any global variables or functions that we have been
1432 putting off. We need to loop in case one of the things emitted
1433 here references another one which comes earlier in the list. */
1437 for (i = 0; i < len; i++)
1441 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
1444 /* Don't write out static consts, unless we still need them.
1446 We also keep static consts if not optimizing (for debugging),
1447 unless the user specified -fno-keep-static-consts.
1448 ??? They might be better written into the debug information.
1449 This is possible when using DWARF.
1451 A language processor that wants static constants to be always
1452 written out (even if it is not used) is responsible for
1453 calling rest_of_decl_compilation itself. E.g. the C front-end
1454 calls rest_of_decl_compilation from finish_decl.
1455 One motivation for this is that is conventional in some
1456 environments to write things like:
1457 static const char rcsid[] = "... version string ...";
1458 intending to force the string to be in the executable.
1460 A language processor that would prefer to have unneeded
1461 static constants "optimized away" would just defer writing
1462 them out until here. E.g. C++ does this, because static
1463 constants are often defined in header files.
1465 ??? A tempting alternative (for both C and C++) would be
1466 to force a constant to be written if and only if it is
1467 defined in a main file, as opposed to an include file. */
1469 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl))
1473 if (flag_unit_at_a_time
1474 && cgraph_varpool_node (decl)->finalized)
1476 else if ((flag_unit_at_a_time && !cgraph_global_info_ready)
1477 && (TREE_USED (decl)
1478 || TREE_USED (DECL_ASSEMBLER_NAME (decl))))
1480 else if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
1482 else if (DECL_COMDAT (decl))
1484 else if (TREE_READONLY (decl) && !TREE_PUBLIC (decl)
1485 && (optimize || !flag_keep_static_consts
1486 || DECL_ARTIFICIAL (decl)))
1492 rest_of_decl_compilation (decl, NULL, 1, 1);
1498 output_something = 1;
1502 return output_something;
1505 /* Issue appropriate warnings for the global declarations in VEC (of
1506 which there are LEN). Output debugging information for them. */
1509 check_global_declarations (tree *vec, int len)
1514 for (i = 0; i < len; i++)
1518 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
1519 && ! TREE_ASM_WRITTEN (decl))
1520 /* Cancel the RTL for this decl so that, if debugging info
1521 output for global variables is still to come,
1522 this one will be omitted. */
1523 SET_DECL_RTL (decl, NULL_RTX);
1525 /* Warn about any function
1526 declared static but not defined.
1527 We don't warn about variables,
1528 because many programs have static variables
1529 that exist only to get some text into the object file. */
1530 if (TREE_CODE (decl) == FUNCTION_DECL
1531 && DECL_INITIAL (decl) == 0
1532 && DECL_EXTERNAL (decl)
1533 && ! DECL_ARTIFICIAL (decl)
1534 && ! TREE_PUBLIC (decl)
1535 && (warn_unused_function
1536 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
1538 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
1539 pedwarn ("%J'%F' used but never defined", decl, decl);
1541 warning ("%J'%F' declared `static' but never defined", decl, decl);
1542 /* This symbol is effectively an "extern" declaration now. */
1543 TREE_PUBLIC (decl) = 1;
1544 assemble_external (decl);
1547 /* Warn about static fns or vars defined but not used. */
1548 if (((warn_unused_function && TREE_CODE (decl) == FUNCTION_DECL)
1549 /* We don't warn about "static const" variables because the
1550 "rcs_id" idiom uses that construction. */
1551 || (warn_unused_variable
1552 && TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
1553 && ! DECL_IN_SYSTEM_HEADER (decl)
1554 && ! TREE_USED (decl)
1555 /* The TREE_USED bit for file-scope decls is kept in the identifier,
1556 to handle multiple external decls in different scopes. */
1557 && ! TREE_USED (DECL_NAME (decl))
1558 && ! DECL_EXTERNAL (decl)
1559 && ! TREE_PUBLIC (decl)
1560 /* A volatile variable might be used in some non-obvious way. */
1561 && ! TREE_THIS_VOLATILE (decl)
1562 /* Global register variables must be declared to reserve them. */
1563 && ! (TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl))
1564 /* Otherwise, ask the language. */
1565 && lang_hooks.decls.warn_unused_global (decl))
1566 warning ("%J'%D' defined but not used", decl, decl);
1568 /* Avoid confusing the debug information machinery when there are
1570 if (errorcount == 0 && sorrycount == 0)
1572 timevar_push (TV_SYMOUT);
1573 (*debug_hooks->global_decl) (decl);
1574 timevar_pop (TV_SYMOUT);
1579 /* Warn about a use of an identifier which was marked deprecated. */
1581 warn_deprecated_use (tree node)
1583 if (node == 0 || !warn_deprecated_decl)
1587 warning ("`%s' is deprecated (declared at %s:%d)",
1588 IDENTIFIER_POINTER (DECL_NAME (node)),
1589 DECL_SOURCE_FILE (node), DECL_SOURCE_LINE (node));
1590 else if (TYPE_P (node))
1592 const char *what = NULL;
1593 tree decl = TYPE_STUB_DECL (node);
1595 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
1596 what = IDENTIFIER_POINTER (TYPE_NAME (node));
1597 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
1598 && DECL_NAME (TYPE_NAME (node)))
1599 what = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node)));
1604 warning ("`%s' is deprecated (declared at %s:%d)", what,
1605 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1607 warning ("`%s' is deprecated", what);
1610 warning ("type is deprecated (declared at %s:%d)",
1611 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1613 warning ("type is deprecated");
1617 /* Save the current INPUT_LOCATION on the top entry in the
1618 INPUT_FILE_STACK. Push a new entry for FILE and LINE, and set the
1619 INPUT_LOCATION accordingly. */
1622 push_srcloc (const char *file, int line)
1624 struct file_stack *fs;
1626 fs = xmalloc (sizeof (struct file_stack));
1627 fs->location = input_location;
1628 fs->next = input_file_stack;
1629 input_filename = file;
1631 input_file_stack = fs;
1632 input_file_stack_tick++;
1635 /* Pop the top entry off the stack of presently open source files.
1636 Restore the INPUT_LOCATION from the new topmost entry on the
1642 struct file_stack *fs;
1644 fs = input_file_stack;
1645 input_location = fs->location;
1646 input_file_stack = fs->next;
1648 input_file_stack_tick++;
1651 /* Compile an entire translation unit. Write a file of assembly
1652 output and various debugging dumps. */
1657 /* Initialize yet another pass. */
1659 init_final (main_input_filename);
1660 coverage_init (aux_base_name);
1662 timevar_push (TV_PARSE);
1664 /* Call the parser, which parses the entire file (calling
1665 rest_of_compilation for each function). */
1666 lang_hooks.parse_file (set_yydebug);
1668 /* In case there were missing block closers,
1669 get us back to the global binding level. */
1670 lang_hooks.clear_binding_stack ();
1672 /* Compilation is now finished except for writing
1673 what's left of the symbol table output. */
1674 timevar_pop (TV_PARSE);
1676 if (flag_syntax_only)
1679 lang_hooks.decls.final_write_globals ();
1681 cgraph_varpool_assemble_pending_decls ();
1683 /* This must occur after the loop to output deferred functions.
1684 Else the coverage initializer would not be emitted if all the
1685 functions in this compilation unit were deferred. */
1688 /* Write out any pending weak symbol declarations. */
1692 /* Do dbx symbols. */
1693 timevar_push (TV_SYMOUT);
1695 #ifdef DWARF2_UNWIND_INFO
1696 if (dwarf2out_do_frame ())
1697 dwarf2out_frame_finish ();
1700 (*debug_hooks->finish) (main_input_filename);
1701 timevar_pop (TV_SYMOUT);
1703 /* Output some stuff at end of file if nec. */
1705 dw2_output_indirect_constants ();
1707 /* Attach a special .ident directive to the end of the file to identify
1708 the version of GCC which compiled this code. The format of the .ident
1709 string is patterned after the ones produced by native SVR4 compilers. */
1712 fprintf (asm_out_file, "%s\"GCC: (GNU) %s\"\n",
1713 IDENT_ASM_OP, version_string);
1716 /* This must be at the end. Some target ports emit end of file directives
1717 into the assembly file here, and hence we can not output anything to the
1718 assembly file after this point. */
1719 targetm.asm_out.file_end ();
1722 /* Display help for target options. */
1724 display_target_options (void)
1727 static bool displayed = false;
1729 /* Avoid double printing for --help --target-help. */
1735 if (ARRAY_SIZE (target_switches) > 1
1736 #ifdef TARGET_OPTIONS
1737 || ARRAY_SIZE (target_options) > 1
1745 printf (_("\nTarget specific options:\n"));
1747 for (i = ARRAY_SIZE (target_switches); i--;)
1749 const char *option = target_switches[i].name;
1750 const char *description = target_switches[i].description;
1752 if (option == NULL || *option == 0)
1754 else if (description == NULL)
1759 printf (_(" -m%-23s [undocumented]\n"), option);
1761 else if (*description != 0)
1762 doc += printf (" -m%-23s %s\n", option, _(description));
1765 #ifdef TARGET_OPTIONS
1766 for (i = ARRAY_SIZE (target_options); i--;)
1768 const char *option = target_options[i].prefix;
1769 const char *description = target_options[i].description;
1771 if (option == NULL || *option == 0)
1773 else if (description == NULL)
1778 printf (_(" -m%-23s [undocumented]\n"), option);
1780 else if (*description != 0)
1781 doc += printf (" -m%-23s %s\n", option, _(description));
1787 printf (_("\nThere are undocumented target specific options as well.\n"));
1789 printf (_(" They exist, but they are not documented.\n"));
1794 /* Parse a -d... command line switch. */
1797 decode_d_option (const char *arg)
1808 flag_print_asm_name = 1;
1811 flag_dump_rtl_in_asm = 1;
1812 flag_print_asm_name = 1;
1815 graph_dump_format = vcg;
1818 rtl_dump_and_exit = 1;
1823 case 'D': /* These are handled by the preprocessor. */
1827 setup_core_dumping();
1832 if (!enable_rtl_dump_file (c))
1833 warning ("unrecognized gcc debugging option: %c", c);
1838 /* Indexed by enum debug_info_type. */
1839 const char *const debug_type_names[] =
1841 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff", "vms"
1844 /* Decode -m switches. */
1845 /* Decode the switch -mNAME. */
1848 set_target_switch (const char *name)
1851 int valid_target_option = 0;
1853 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
1854 if (!strcmp (target_switches[j].name, name))
1856 if (target_switches[j].value < 0)
1857 target_flags &= ~-target_switches[j].value;
1859 target_flags |= target_switches[j].value;
1862 if (target_switches[j].value < 0)
1863 target_flags_explicit |= -target_switches[j].value;
1865 target_flags_explicit |= target_switches[j].value;
1867 valid_target_option = 1;
1870 #ifdef TARGET_OPTIONS
1871 if (!valid_target_option)
1872 for (j = 0; j < ARRAY_SIZE (target_options); j++)
1874 int len = strlen (target_options[j].prefix);
1875 if (target_options[j].value)
1877 if (!strcmp (target_options[j].prefix, name))
1879 *target_options[j].variable = target_options[j].value;
1880 valid_target_option = 1;
1885 if (!strncmp (target_options[j].prefix, name, len))
1887 *target_options[j].variable = name + len;
1888 valid_target_option = 1;
1894 if (!valid_target_option)
1895 error ("invalid option `%s'", name);
1898 /* Print version information to FILE.
1899 Each line begins with INDENT (for the case where FILE is the
1900 assembler output file). */
1903 print_version (FILE *file, const char *indent)
1906 #define __VERSION__ "[?]"
1910 "%s%s%s version %s (%s)\n%s\tcompiled by GNU C version %s.\n"
1912 "%s%s%s version %s (%s) compiled by CC.\n"
1914 , indent, *indent != 0 ? " " : "",
1915 lang_hooks.name, version_string, TARGET_NAME,
1916 indent, __VERSION__);
1917 fnotice (file, "%s%sGGC heuristics: --param ggc-min-expand=%d --param ggc-min-heapsize=%d\n",
1918 indent, *indent != 0 ? " " : "",
1919 PARAM_VALUE (GGC_MIN_EXPAND), PARAM_VALUE (GGC_MIN_HEAPSIZE));
1922 /* Print an option value and return the adjusted position in the line.
1923 ??? We don't handle error returns from fprintf (disk full); presumably
1924 other code will catch a disk full though. */
1927 print_single_switch (FILE *file, int pos, int max,
1928 const char *indent, const char *sep, const char *term,
1929 const char *type, const char *name)
1931 /* The ultrix fprintf returns 0 on success, so compute the result we want
1932 here since we need it for the following test. */
1933 int len = strlen (sep) + strlen (type) + strlen (name);
1938 fprintf (file, "%s", term);
1943 fprintf (file, "%s", indent);
1944 pos = strlen (indent);
1946 fprintf (file, "%s%s%s", sep, type, name);
1951 /* Print active target switches to FILE.
1952 POS is the current cursor position and MAX is the size of a "line".
1953 Each line begins with INDENT and ends with TERM.
1954 Each switch is separated from the next by SEP. */
1957 print_switch_values (FILE *file, int pos, int max,
1958 const char *indent, const char *sep, const char *term)
1963 /* Fill in the -frandom-seed option, if the user didn't pass it, so
1964 that it can be printed below. This helps reproducibility. */
1967 /* Print the options as passed. */
1968 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
1969 _("options passed: "), "");
1971 for (p = &save_argv[1]; *p != NULL; p++)
1975 if (strcmp (*p, "-o") == 0)
1981 if (strcmp (*p, "-quiet") == 0)
1983 if (strcmp (*p, "-version") == 0)
1988 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
1991 fprintf (file, "%s", term);
1993 /* Print the -f and -m options that have been enabled.
1994 We don't handle language specific options but printing argv
1997 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
1998 _("options enabled: "), "");
2000 for (j = 0; j < ARRAY_SIZE (f_options); j++)
2001 if (*f_options[j].variable == f_options[j].on_value)
2002 pos = print_single_switch (file, pos, max, indent, sep, term,
2003 "-f", f_options[j].string);
2005 /* Print target specific options. */
2007 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
2008 if (target_switches[j].name[0] != '\0'
2009 && target_switches[j].value > 0
2010 && ((target_switches[j].value & target_flags)
2011 == target_switches[j].value))
2013 pos = print_single_switch (file, pos, max, indent, sep, term,
2014 "-m", target_switches[j].name);
2017 #ifdef TARGET_OPTIONS
2018 for (j = 0; j < ARRAY_SIZE (target_options); j++)
2019 if (*target_options[j].variable != NULL)
2022 sprintf (prefix, "-m%s", target_options[j].prefix);
2023 pos = print_single_switch (file, pos, max, indent, sep, term,
2024 prefix, *target_options[j].variable);
2028 fprintf (file, "%s", term);
2031 /* Open assembly code output file. Do this even if -fsyntax-only is
2032 on, because then the driver will have provided the name of a
2033 temporary file or bit bucket for us. NAME is the file specified on
2034 the command line, possibly NULL. */
2036 init_asm_output (const char *name)
2038 if (name == NULL && asm_file_name == 0)
2039 asm_out_file = stdout;
2042 if (asm_file_name == 0)
2044 int len = strlen (dump_base_name);
2045 char *dumpname = xmalloc (len + 6);
2046 memcpy (dumpname, dump_base_name, len + 1);
2047 strip_off_ending (dumpname, len);
2048 strcat (dumpname, ".s");
2049 asm_file_name = dumpname;
2051 if (!strcmp (asm_file_name, "-"))
2052 asm_out_file = stdout;
2054 asm_out_file = fopen (asm_file_name, "w+b");
2055 if (asm_out_file == 0)
2056 fatal_error ("can't open %s for writing: %m", asm_file_name);
2059 #ifdef IO_BUFFER_SIZE
2060 setvbuf (asm_out_file, xmalloc (IO_BUFFER_SIZE),
2061 _IOFBF, IO_BUFFER_SIZE);
2064 if (!flag_syntax_only)
2066 targetm.asm_out.file_start ();
2068 #ifdef ASM_COMMENT_START
2069 if (flag_verbose_asm)
2071 /* Print the list of options in effect. */
2072 print_version (asm_out_file, ASM_COMMENT_START);
2073 print_switch_values (asm_out_file, 0, MAX_LINE,
2074 ASM_COMMENT_START, " ", "\n");
2075 /* Add a blank line here so it appears in assembler output but not
2077 fprintf (asm_out_file, "\n");
2083 /* Default version of get_pch_validity.
2084 By default, every flag difference is fatal; that will be mostly right for
2085 most targets, but completely right for very few. */
2088 default_get_pch_validity (size_t *len)
2090 #ifdef TARGET_OPTIONS
2095 *len = sizeof (target_flags) + 2;
2096 #ifdef TARGET_OPTIONS
2097 for (i = 0; i < ARRAY_SIZE (target_options); i++)
2100 if (*target_options[i].variable)
2101 *len += strlen (*target_options[i].variable);
2105 result = r = xmalloc (*len);
2109 memcpy (r, &target_flags, sizeof (target_flags));
2110 r += sizeof (target_flags);
2112 #ifdef TARGET_OPTIONS
2113 for (i = 0; i < ARRAY_SIZE (target_options); i++)
2115 const char *str = *target_options[i].variable;
2119 l = strlen (str) + 1;
2128 /* Default version of pch_valid_p. */
2131 default_pch_valid_p (const void *data_p, size_t len)
2133 const char *data = (const char *)data_p;
2134 const char *flag_that_differs = NULL;
2137 /* -fpic and -fpie also usually make a PCH invalid. */
2138 if (data[0] != flag_pic)
2139 return _("created and used with different settings of -fpic");
2140 if (data[1] != flag_pie)
2141 return _("created and used with different settings of -fpie");
2144 /* Check target_flags. */
2145 if (memcmp (data, &target_flags, sizeof (target_flags)) != 0)
2147 for (i = 0; i < ARRAY_SIZE (target_switches); i++)
2152 memcpy (&tf, data, sizeof (target_flags));
2154 bits = target_switches[i].value;
2157 if ((target_flags & bits) != (tf & bits))
2159 flag_that_differs = target_switches[i].name;
2165 data += sizeof (target_flags);
2166 len -= sizeof (target_flags);
2168 /* Check string options. */
2169 #ifdef TARGET_OPTIONS
2170 for (i = 0; i < ARRAY_SIZE (target_options); i++)
2172 const char *str = *target_options[i].variable;
2176 l = strlen (str) + 1;
2177 if (len < l || memcmp (data, str, l) != 0)
2179 flag_that_differs = target_options[i].prefix;
2192 asprintf (&r, _("created and used with differing settings of `-m%s'"),
2195 return _("out of memory");
2200 /* Default tree printer. Handles declarations only. */
2202 default_tree_printer (pretty_printer * pp, text_info *text)
2204 switch (*text->format_spec)
2210 tree t = va_arg (*text->args_ptr, tree);
2211 const char *n = DECL_NAME (t)
2212 ? lang_hooks.decl_printable_name (t, 2)
2223 /* Initialization of the front end environment, before command line
2224 options are parsed. Signal handlers, internationalization etc.
2225 ARGV0 is main's argv[0]. */
2227 general_init (const char *argv0)
2231 p = argv0 + strlen (argv0);
2232 while (p != argv0 && !IS_DIR_SEPARATOR (p[-1]))
2236 xmalloc_set_program_name (progname);
2240 gcc_init_libintl ();
2242 /* Initialize the diagnostics reporting machinery, so option parsing
2243 can give warnings and errors. */
2244 diagnostic_initialize (global_dc);
2245 /* Set a default printer. Language specific initializations will
2246 override it later. */
2247 pp_format_decoder (global_dc->printer) = &default_tree_printer;
2249 /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages. */
2251 signal (SIGSEGV, crash_signal);
2254 signal (SIGILL, crash_signal);
2257 signal (SIGBUS, crash_signal);
2260 signal (SIGABRT, crash_signal);
2262 #if defined SIGIOT && (!defined SIGABRT || SIGABRT != SIGIOT)
2263 signal (SIGIOT, crash_signal);
2266 signal (SIGFPE, crash_signal);
2269 /* Other host-specific signal setup. */
2270 (*host_hooks.extra_signals)();
2272 /* Initialize the garbage-collector, string pools and tree type hash
2276 linemap_init (&line_table);
2279 /* Initialize register usage now so switches may override. */
2282 /* Register the language-independent parameters. */
2283 add_params (lang_independent_params, LAST_PARAM);
2285 /* This must be done after add_params but before argument processing. */
2286 init_ggc_heuristics();
2287 init_tree_optimization_passes ();
2290 /* Process the options that have been parsed. */
2292 process_options (void)
2294 /* Allow the front end to perform consistency checks and do further
2295 initialization based on the command line options. This hook also
2296 sets the original filename if appropriate (e.g. foo.i -> foo.c)
2297 so we can correctly initialize debug output. */
2298 no_backend = lang_hooks.post_options (&main_input_filename);
2299 input_filename = main_input_filename;
2301 #ifdef OVERRIDE_OPTIONS
2302 /* Some machines may reject certain combinations of options. */
2306 if (flag_short_enums == 2)
2307 flag_short_enums = targetm.default_short_enums ();
2309 /* Set aux_base_name if not already set. */
2312 else if (main_input_filename)
2314 char *name = xstrdup (lbasename (main_input_filename));
2316 strip_off_ending (name, strlen (name));
2317 aux_base_name = name;
2320 aux_base_name = "gccaux";
2322 /* Set up the align_*_log variables, defaulting them to 1 if they
2323 were still unset. */
2324 if (align_loops <= 0) align_loops = 1;
2325 if (align_loops_max_skip > align_loops || !align_loops)
2326 align_loops_max_skip = align_loops - 1;
2327 align_loops_log = floor_log2 (align_loops * 2 - 1);
2328 if (align_jumps <= 0) align_jumps = 1;
2329 if (align_jumps_max_skip > align_jumps || !align_jumps)
2330 align_jumps_max_skip = align_jumps - 1;
2331 align_jumps_log = floor_log2 (align_jumps * 2 - 1);
2332 if (align_labels <= 0) align_labels = 1;
2333 align_labels_log = floor_log2 (align_labels * 2 - 1);
2334 if (align_labels_max_skip > align_labels || !align_labels)
2335 align_labels_max_skip = align_labels - 1;
2336 if (align_functions <= 0) align_functions = 1;
2337 align_functions_log = floor_log2 (align_functions * 2 - 1);
2339 /* Unrolling all loops implies that standard loop unrolling must also
2341 if (flag_unroll_all_loops)
2342 flag_unroll_loops = 1;
2344 if (flag_unroll_loops)
2346 flag_old_unroll_loops = 0;
2347 flag_old_unroll_all_loops = 0;
2350 if (flag_old_unroll_all_loops)
2351 flag_old_unroll_loops = 1;
2353 /* Old loop unrolling requires that strength_reduction be on also. Silently
2354 turn on strength reduction here if it isn't already on. Also, the loop
2355 unrolling code assumes that cse will be run after loop, so that must
2356 be turned on also. */
2357 if (flag_old_unroll_loops)
2359 flag_strength_reduce = 1;
2360 flag_rerun_cse_after_loop = 1;
2362 if (flag_unroll_loops || flag_peel_loops)
2363 flag_rerun_cse_after_loop = 1;
2365 if (flag_non_call_exceptions)
2366 flag_asynchronous_unwind_tables = 1;
2367 if (flag_asynchronous_unwind_tables)
2368 flag_unwind_tables = 1;
2370 /* Disable unit-at-a-time mode for frontends not supporting callgraph
2372 if (flag_unit_at_a_time && ! lang_hooks.callgraph.expand_function)
2373 flag_unit_at_a_time = 0;
2375 if (flag_value_profile_transformations)
2376 flag_profile_values = 1;
2378 /* Warn about options that are not supported on this machine. */
2379 #ifndef INSN_SCHEDULING
2380 if (flag_schedule_insns || flag_schedule_insns_after_reload)
2381 warning ("instruction scheduling not supported on this target machine");
2384 if (flag_delayed_branch)
2385 warning ("this target machine does not have delayed branches");
2388 if (flag_tree_based_profiling && flag_test_coverage)
2389 sorry ("test-coverage not yet implemented in trees.");
2390 if (flag_tree_based_profiling && flag_profile_values)
2391 sorry ("value-based profiling not yet implemented in trees.");
2393 user_label_prefix = USER_LABEL_PREFIX;
2394 if (flag_leading_underscore != -1)
2396 /* If the default prefix is more complicated than "" or "_",
2397 issue a warning and ignore this option. */
2398 if (user_label_prefix[0] == 0 ||
2399 (user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
2401 user_label_prefix = flag_leading_underscore ? "_" : "";
2404 warning ("-f%sleading-underscore not supported on this target machine",
2405 flag_leading_underscore ? "" : "no-");
2408 /* If we are in verbose mode, write out the version and maybe all the
2409 option flags in use. */
2412 print_version (stderr, "");
2414 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
2417 if (flag_syntax_only)
2419 write_symbols = NO_DEBUG;
2423 /* A lot of code assumes write_symbols == NO_DEBUG if the debugging
2425 if (debug_info_level == DINFO_LEVEL_NONE)
2426 write_symbols = NO_DEBUG;
2428 /* Now we know write_symbols, set up the debug hooks based on it.
2429 By default we do nothing for debug output. */
2430 if (PREFERRED_DEBUGGING_TYPE == NO_DEBUG)
2431 default_debug_hooks = &do_nothing_debug_hooks;
2432 #if defined(DBX_DEBUGGING_INFO)
2433 else if (PREFERRED_DEBUGGING_TYPE == DBX_DEBUG)
2434 default_debug_hooks = &dbx_debug_hooks;
2436 #if defined(XCOFF_DEBUGGING_INFO)
2437 else if (PREFERRED_DEBUGGING_TYPE == XCOFF_DEBUG)
2438 default_debug_hooks = &xcoff_debug_hooks;
2440 #ifdef SDB_DEBUGGING_INFO
2441 else if (PREFERRED_DEBUGGING_TYPE == SDB_DEBUG)
2442 default_debug_hooks = &sdb_debug_hooks;
2444 #ifdef DWARF2_DEBUGGING_INFO
2445 else if (PREFERRED_DEBUGGING_TYPE == DWARF2_DEBUG)
2446 default_debug_hooks = &dwarf2_debug_hooks;
2448 #ifdef VMS_DEBUGGING_INFO
2449 else if (PREFERRED_DEBUGGING_TYPE == VMS_DEBUG
2450 || PREFERRED_DEBUGGING_TYPE == VMS_AND_DWARF2_DEBUG)
2451 default_debug_hooks = &vmsdbg_debug_hooks;
2454 if (write_symbols == NO_DEBUG)
2455 debug_hooks = &do_nothing_debug_hooks;
2456 #if defined(DBX_DEBUGGING_INFO)
2457 else if (write_symbols == DBX_DEBUG)
2458 debug_hooks = &dbx_debug_hooks;
2460 #if defined(XCOFF_DEBUGGING_INFO)
2461 else if (write_symbols == XCOFF_DEBUG)
2462 debug_hooks = &xcoff_debug_hooks;
2464 #ifdef SDB_DEBUGGING_INFO
2465 else if (write_symbols == SDB_DEBUG)
2466 debug_hooks = &sdb_debug_hooks;
2468 #ifdef DWARF2_DEBUGGING_INFO
2469 else if (write_symbols == DWARF2_DEBUG)
2470 debug_hooks = &dwarf2_debug_hooks;
2472 #ifdef VMS_DEBUGGING_INFO
2473 else if (write_symbols == VMS_DEBUG || write_symbols == VMS_AND_DWARF2_DEBUG)
2474 debug_hooks = &vmsdbg_debug_hooks;
2477 error ("target system does not support the \"%s\" debug format",
2478 debug_type_names[write_symbols]);
2480 /* Now we know which debug output will be used so we can set
2481 flag_var_tracking, flag_rename_registers and flag_web if the user has
2482 not specified them. */
2483 if (debug_info_level < DINFO_LEVEL_NORMAL
2484 || debug_hooks->var_location == do_nothing_debug_hooks.var_location)
2486 if (flag_var_tracking == 1)
2488 if (debug_info_level < DINFO_LEVEL_NORMAL)
2489 warning ("variable tracking requested, but useless unless "
2490 "producing debug info");
2492 warning ("variable tracking requested, but not supported "
2493 "by this debug format");
2495 flag_var_tracking = 0;
2498 if (flag_rename_registers == AUTODETECT_FLAG_VAR_TRACKING)
2499 flag_rename_registers = default_debug_hooks->var_location
2500 != do_nothing_debug_hooks.var_location;
2502 if (flag_web == AUTODETECT_FLAG_VAR_TRACKING)
2503 flag_web = optimize >= 2 && (default_debug_hooks->var_location
2504 != do_nothing_debug_hooks.var_location);
2506 if (flag_var_tracking == AUTODETECT_FLAG_VAR_TRACKING)
2507 flag_var_tracking = optimize >= 1;
2509 /* If auxiliary info generation is desired, open the output file.
2510 This goes in the same directory as the source file--unlike
2511 all the other output files. */
2512 if (flag_gen_aux_info)
2514 aux_info_file = fopen (aux_info_file_name, "w");
2515 if (aux_info_file == 0)
2516 fatal_error ("can't open %s: %m", aux_info_file_name);
2519 if (! targetm.have_named_sections)
2521 if (flag_function_sections)
2523 warning ("-ffunction-sections not supported for this target");
2524 flag_function_sections = 0;
2526 if (flag_data_sections)
2528 warning ("-fdata-sections not supported for this target");
2529 flag_data_sections = 0;
2533 if (flag_function_sections && profile_flag)
2535 warning ("-ffunction-sections disabled; it makes profiling impossible");
2536 flag_function_sections = 0;
2539 #ifndef HAVE_prefetch
2540 if (flag_prefetch_loop_arrays)
2542 warning ("-fprefetch-loop-arrays not supported for this target");
2543 flag_prefetch_loop_arrays = 0;
2546 if (flag_prefetch_loop_arrays && !HAVE_prefetch)
2548 warning ("-fprefetch-loop-arrays not supported for this target (try -march switches)");
2549 flag_prefetch_loop_arrays = 0;
2553 /* This combination of options isn't handled for i386 targets and doesn't
2554 make much sense anyway, so don't allow it. */
2555 if (flag_prefetch_loop_arrays && optimize_size)
2557 warning ("-fprefetch-loop-arrays is not supported with -Os");
2558 flag_prefetch_loop_arrays = 0;
2561 #ifndef OBJECT_FORMAT_ELF
2562 if (flag_function_sections && write_symbols != NO_DEBUG)
2563 warning ("-ffunction-sections may affect debugging on some targets");
2566 /* The presence of IEEE signaling NaNs, implies all math can trap. */
2567 if (flag_signaling_nans)
2568 flag_trapping_math = 1;
2571 /* Initialize the compiler back end. */
2575 init_adjust_machine_modes ();
2577 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2578 || debug_info_level == DINFO_LEVEL_VERBOSE
2579 #ifdef VMS_DEBUGGING_INFO
2580 /* Enable line number info for traceback. */
2581 || debug_info_level > DINFO_LEVEL_NONE
2583 || flag_test_coverage
2584 || warn_notreached);
2587 init_fake_stack_mems ();
2591 init_function_once ();
2592 init_varasm_once ();
2594 /* The following initialization functions need to generate rtl, so
2595 provide a dummy function context for them. */
2596 init_dummy_function_start ();
2598 if (flag_caller_saves)
2599 init_caller_save ();
2600 expand_dummy_function_end ();
2603 /* Language-dependent initialization. Returns nonzero on success. */
2605 lang_dependent_init (const char *name)
2607 if (dump_base_name == 0)
2608 dump_base_name = name ? name : "gccdump";
2610 /* Other front-end initialization. */
2611 if (lang_hooks.init () == 0)
2614 init_asm_output (name);
2616 /* These create various _DECL nodes, so need to be called after the
2617 front end is initialized. */
2620 init_optimization_passes ();
2622 /* The following initialization functions need to generate rtl, so
2623 provide a dummy function context for them. */
2624 init_dummy_function_start ();
2626 expand_dummy_function_end ();
2628 /* If dbx symbol table desired, initialize writing it and output the
2629 predefined types. */
2630 timevar_push (TV_SYMOUT);
2632 #ifdef DWARF2_UNWIND_INFO
2633 if (dwarf2out_do_frame ())
2634 dwarf2out_frame_init ();
2637 /* Now we have the correct original filename, we can initialize
2639 (*debug_hooks->init) (name);
2641 timevar_pop (TV_SYMOUT);
2646 /* Clean up: close opened files, etc. */
2651 /* Close the dump files. */
2652 if (flag_gen_aux_info)
2654 fclose (aux_info_file);
2656 unlink (aux_info_file_name);
2659 /* Close non-debugging input and output files. Take special care to note
2660 whether fclose returns an error, since the pages might still be on the
2661 buffer chain while the file is open. */
2665 if (ferror (asm_out_file) != 0)
2666 fatal_error ("error writing to %s: %m", asm_file_name);
2667 if (fclose (asm_out_file) != 0)
2668 fatal_error ("error closing %s: %m", asm_file_name);
2671 finish_optimization_passes ();
2675 ggc_print_statistics ();
2676 stringpool_statistics ();
2677 dump_tree_statistics ();
2678 dump_rtx_statistics ();
2679 dump_varray_statistics ();
2680 dump_alloc_pool_statistics ();
2681 dump_ggc_loc_statistics ();
2684 /* Free up memory for the benefit of leak detectors. */
2687 /* Language-specific end of compilation actions. */
2688 lang_hooks.finish ();
2691 /* Initialize the compiler, and compile the input file. */
2695 /* Initialize timing first. The C front ends read the main file in
2696 the post_options hook, and C++ does file timings. */
2697 if (time_report || !quiet_flag || flag_detailed_statistics)
2699 timevar_start (TV_TOTAL);
2703 /* Don't do any more if an error has already occurred. */
2706 /* Set up the back-end if requested. */
2710 /* Language-dependent initialization. Returns true on success. */
2711 if (lang_dependent_init (main_input_filename))
2717 /* Stop timing and print the times. */
2718 timevar_stop (TV_TOTAL);
2719 timevar_print (stderr);
2722 /* Entry point of cc1, cc1plus, jc1, f771, etc.
2723 Exit code is FATAL_EXIT_CODE if can't open files or if there were
2724 any errors, or SUCCESS_EXIT_CODE if compilation succeeded.
2726 It is not safe to call this function more than once. */
2729 toplev_main (unsigned int argc, const char **argv)
2733 /* Initialization of GCC's environment, and diagnostics. */
2734 general_init (argv[0]);
2736 /* Parse the options and do minimal processing; basically just
2737 enough to default flags appropriately. */
2738 decode_options (argc, argv);
2742 /* Exit early if we can (e.g. -help). */
2743 if (!exit_after_options)
2746 if (errorcount || sorrycount)
2747 return (FATAL_EXIT_CODE);
2749 return (SUCCESS_EXIT_CODE);