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 /* Return the logarithm of X, base 2, considering X unsigned,
1252 if X is a power of 2. Otherwise, returns -1.
1254 This should be used via the `exact_log2' macro. */
1257 exact_log2_wide (unsigned HOST_WIDE_INT x)
1260 /* Test for 0 or a power of 2. */
1261 if (x == 0 || x != (x & -x))
1263 while ((x >>= 1) != 0)
1268 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1269 If X is 0, return -1.
1271 This should be used via the floor_log2 macro. */
1274 floor_log2_wide (unsigned HOST_WIDE_INT x)
1283 /* Handler for fatal signals, such as SIGSEGV. These are transformed
1284 into ICE messages, which is much more user friendly. In case the
1285 error printer crashes, reset the signal to prevent infinite recursion. */
1288 crash_signal (int signo)
1290 signal (signo, SIG_DFL);
1291 internal_error ("%s", strsignal (signo));
1294 /* Arrange to dump core on error. (The regular error message is still
1295 printed first, except in the case of abort().) */
1298 setup_core_dumping (void)
1301 signal (SIGABRT, SIG_DFL);
1303 #if defined(HAVE_SETRLIMIT)
1306 if (getrlimit (RLIMIT_CORE, &rlim) != 0)
1307 fatal_error ("getting core file size maximum limit: %m");
1308 rlim.rlim_cur = rlim.rlim_max;
1309 if (setrlimit (RLIMIT_CORE, &rlim) != 0)
1310 fatal_error ("setting core file size limit to maximum: %m");
1313 diagnostic_abort_on_error (global_dc);
1317 /* Strip off a legitimate source ending from the input string NAME of
1318 length LEN. Rather than having to know the names used by all of
1319 our front ends, we strip off an ending of a period followed by
1320 up to five characters. (Java uses ".class".) */
1323 strip_off_ending (char *name, int len)
1326 for (i = 2; i < 6 && len > i; i++)
1328 if (name[len - i] == '.')
1330 name[len - i] = '\0';
1336 /* Output a quoted string. */
1339 output_quoted_string (FILE *asm_file, const char *string)
1341 #ifdef OUTPUT_QUOTED_STRING
1342 OUTPUT_QUOTED_STRING (asm_file, string);
1346 putc ('\"', asm_file);
1347 while ((c = *string++) != 0)
1351 if (c == '\"' || c == '\\')
1352 putc ('\\', asm_file);
1356 fprintf (asm_file, "\\%03o", (unsigned char) c);
1358 putc ('\"', asm_file);
1362 /* Output a file name in the form wanted by System V. */
1365 output_file_directive (FILE *asm_file, const char *input_name)
1370 if (input_name == NULL)
1371 input_name = "<stdin>";
1373 len = strlen (input_name);
1374 na = input_name + len;
1376 /* NA gets INPUT_NAME sans directory names. */
1377 while (na > input_name)
1379 if (IS_DIR_SEPARATOR (na[-1]))
1384 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1385 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1387 fprintf (asm_file, "\t.file\t");
1388 output_quoted_string (asm_file, na);
1389 fputc ('\n', asm_file);
1393 /* Do any final processing required for the declarations in VEC, of
1394 which there are LEN. We write out inline functions and variables
1395 that have been deferred until this point, but which are required.
1396 Returns nonzero if anything was put out. */
1399 wrapup_global_declarations (tree *vec, int len)
1404 int output_something = 0;
1406 for (i = 0; i < len; i++)
1410 /* We're not deferring this any longer. Assignment is
1411 conditional to avoid needlessly dirtying PCH pages. */
1412 if (DECL_DEFER_OUTPUT (decl) != 0)
1413 DECL_DEFER_OUTPUT (decl) = 0;
1415 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0)
1416 lang_hooks.finish_incomplete_decl (decl);
1419 /* Now emit any global variables or functions that we have been
1420 putting off. We need to loop in case one of the things emitted
1421 here references another one which comes earlier in the list. */
1425 for (i = 0; i < len; i++)
1429 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
1432 /* Don't write out static consts, unless we still need them.
1434 We also keep static consts if not optimizing (for debugging),
1435 unless the user specified -fno-keep-static-consts.
1436 ??? They might be better written into the debug information.
1437 This is possible when using DWARF.
1439 A language processor that wants static constants to be always
1440 written out (even if it is not used) is responsible for
1441 calling rest_of_decl_compilation itself. E.g. the C front-end
1442 calls rest_of_decl_compilation from finish_decl.
1443 One motivation for this is that is conventional in some
1444 environments to write things like:
1445 static const char rcsid[] = "... version string ...";
1446 intending to force the string to be in the executable.
1448 A language processor that would prefer to have unneeded
1449 static constants "optimized away" would just defer writing
1450 them out until here. E.g. C++ does this, because static
1451 constants are often defined in header files.
1453 ??? A tempting alternative (for both C and C++) would be
1454 to force a constant to be written if and only if it is
1455 defined in a main file, as opposed to an include file. */
1457 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl))
1461 if (flag_unit_at_a_time
1462 && cgraph_varpool_node (decl)->finalized)
1464 else if ((flag_unit_at_a_time && !cgraph_global_info_ready)
1465 && (TREE_USED (decl)
1466 || TREE_USED (DECL_ASSEMBLER_NAME (decl))))
1468 else if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
1470 else if (DECL_COMDAT (decl))
1472 else if (TREE_READONLY (decl) && !TREE_PUBLIC (decl)
1473 && (optimize || !flag_keep_static_consts
1474 || DECL_ARTIFICIAL (decl)))
1480 rest_of_decl_compilation (decl, NULL, 1, 1);
1486 output_something = 1;
1490 return output_something;
1493 /* Issue appropriate warnings for the global declarations in VEC (of
1494 which there are LEN). Output debugging information for them. */
1497 check_global_declarations (tree *vec, int len)
1502 for (i = 0; i < len; i++)
1506 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
1507 && ! TREE_ASM_WRITTEN (decl))
1508 /* Cancel the RTL for this decl so that, if debugging info
1509 output for global variables is still to come,
1510 this one will be omitted. */
1511 SET_DECL_RTL (decl, NULL_RTX);
1513 /* Warn about any function
1514 declared static but not defined.
1515 We don't warn about variables,
1516 because many programs have static variables
1517 that exist only to get some text into the object file. */
1518 if (TREE_CODE (decl) == FUNCTION_DECL
1519 && DECL_INITIAL (decl) == 0
1520 && DECL_EXTERNAL (decl)
1521 && ! DECL_ARTIFICIAL (decl)
1522 && ! TREE_PUBLIC (decl)
1523 && (warn_unused_function
1524 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
1526 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
1527 pedwarn ("%J'%F' used but never defined", decl, decl);
1529 warning ("%J'%F' declared `static' but never defined", decl, decl);
1530 /* This symbol is effectively an "extern" declaration now. */
1531 TREE_PUBLIC (decl) = 1;
1532 assemble_external (decl);
1535 /* Warn about static fns or vars defined but not used. */
1536 if (((warn_unused_function && TREE_CODE (decl) == FUNCTION_DECL)
1537 /* We don't warn about "static const" variables because the
1538 "rcs_id" idiom uses that construction. */
1539 || (warn_unused_variable
1540 && TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
1541 && ! DECL_IN_SYSTEM_HEADER (decl)
1542 && ! TREE_USED (decl)
1543 /* The TREE_USED bit for file-scope decls is kept in the identifier,
1544 to handle multiple external decls in different scopes. */
1545 && ! TREE_USED (DECL_NAME (decl))
1546 && ! DECL_EXTERNAL (decl)
1547 && ! TREE_PUBLIC (decl)
1548 /* A volatile variable might be used in some non-obvious way. */
1549 && ! TREE_THIS_VOLATILE (decl)
1550 /* Global register variables must be declared to reserve them. */
1551 && ! (TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl))
1552 /* Otherwise, ask the language. */
1553 && lang_hooks.decls.warn_unused_global (decl))
1554 warning ("%J'%D' defined but not used", decl, decl);
1556 /* Avoid confusing the debug information machinery when there are
1558 if (errorcount == 0 && sorrycount == 0)
1560 timevar_push (TV_SYMOUT);
1561 (*debug_hooks->global_decl) (decl);
1562 timevar_pop (TV_SYMOUT);
1567 /* Warn about a use of an identifier which was marked deprecated. */
1569 warn_deprecated_use (tree node)
1571 if (node == 0 || !warn_deprecated_decl)
1575 warning ("`%s' is deprecated (declared at %s:%d)",
1576 IDENTIFIER_POINTER (DECL_NAME (node)),
1577 DECL_SOURCE_FILE (node), DECL_SOURCE_LINE (node));
1578 else if (TYPE_P (node))
1580 const char *what = NULL;
1581 tree decl = TYPE_STUB_DECL (node);
1583 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
1584 what = IDENTIFIER_POINTER (TYPE_NAME (node));
1585 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
1586 && DECL_NAME (TYPE_NAME (node)))
1587 what = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node)));
1592 warning ("`%s' is deprecated (declared at %s:%d)", what,
1593 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1595 warning ("`%s' is deprecated", what);
1598 warning ("type is deprecated (declared at %s:%d)",
1599 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1601 warning ("type is deprecated");
1605 /* Save the current INPUT_LOCATION on the top entry in the
1606 INPUT_FILE_STACK. Push a new entry for FILE and LINE, and set the
1607 INPUT_LOCATION accordingly. */
1610 push_srcloc (const char *file, int line)
1612 struct file_stack *fs;
1614 fs = xmalloc (sizeof (struct file_stack));
1615 fs->location = input_location;
1616 fs->next = input_file_stack;
1617 input_filename = file;
1619 input_file_stack = fs;
1620 input_file_stack_tick++;
1623 /* Pop the top entry off the stack of presently open source files.
1624 Restore the INPUT_LOCATION from the new topmost entry on the
1630 struct file_stack *fs;
1632 fs = input_file_stack;
1633 input_location = fs->location;
1634 input_file_stack = fs->next;
1636 input_file_stack_tick++;
1639 /* Compile an entire translation unit. Write a file of assembly
1640 output and various debugging dumps. */
1645 /* Initialize yet another pass. */
1647 init_final (main_input_filename);
1648 coverage_init (aux_base_name);
1650 timevar_push (TV_PARSE);
1652 /* Call the parser, which parses the entire file (calling
1653 rest_of_compilation for each function). */
1654 lang_hooks.parse_file (set_yydebug);
1656 /* In case there were missing block closers,
1657 get us back to the global binding level. */
1658 lang_hooks.clear_binding_stack ();
1660 /* Compilation is now finished except for writing
1661 what's left of the symbol table output. */
1662 timevar_pop (TV_PARSE);
1664 if (flag_syntax_only)
1667 lang_hooks.decls.final_write_globals ();
1669 cgraph_varpool_assemble_pending_decls ();
1671 /* This must occur after the loop to output deferred functions.
1672 Else the coverage initializer would not be emitted if all the
1673 functions in this compilation unit were deferred. */
1676 /* Write out any pending weak symbol declarations. */
1680 /* Do dbx symbols. */
1681 timevar_push (TV_SYMOUT);
1683 #ifdef DWARF2_UNWIND_INFO
1684 if (dwarf2out_do_frame ())
1685 dwarf2out_frame_finish ();
1688 (*debug_hooks->finish) (main_input_filename);
1689 timevar_pop (TV_SYMOUT);
1691 /* Output some stuff at end of file if nec. */
1693 dw2_output_indirect_constants ();
1695 /* Attach a special .ident directive to the end of the file to identify
1696 the version of GCC which compiled this code. The format of the .ident
1697 string is patterned after the ones produced by native SVR4 compilers. */
1700 fprintf (asm_out_file, "%s\"GCC: (GNU) %s\"\n",
1701 IDENT_ASM_OP, version_string);
1704 /* This must be at the end. Some target ports emit end of file directives
1705 into the assembly file here, and hence we can not output anything to the
1706 assembly file after this point. */
1707 targetm.asm_out.file_end ();
1710 /* Display help for target options. */
1712 display_target_options (void)
1715 static bool displayed = false;
1717 /* Avoid double printing for --help --target-help. */
1723 if (ARRAY_SIZE (target_switches) > 1
1724 #ifdef TARGET_OPTIONS
1725 || ARRAY_SIZE (target_options) > 1
1733 printf (_("\nTarget specific options:\n"));
1735 for (i = ARRAY_SIZE (target_switches); i--;)
1737 const char *option = target_switches[i].name;
1738 const char *description = target_switches[i].description;
1740 if (option == NULL || *option == 0)
1742 else if (description == NULL)
1747 printf (_(" -m%-23s [undocumented]\n"), option);
1749 else if (*description != 0)
1750 doc += printf (" -m%-23s %s\n", option, _(description));
1753 #ifdef TARGET_OPTIONS
1754 for (i = ARRAY_SIZE (target_options); i--;)
1756 const char *option = target_options[i].prefix;
1757 const char *description = target_options[i].description;
1759 if (option == NULL || *option == 0)
1761 else if (description == NULL)
1766 printf (_(" -m%-23s [undocumented]\n"), option);
1768 else if (*description != 0)
1769 doc += printf (" -m%-23s %s\n", option, _(description));
1775 printf (_("\nThere are undocumented target specific options as well.\n"));
1777 printf (_(" They exist, but they are not documented.\n"));
1782 /* Parse a -d... command line switch. */
1785 decode_d_option (const char *arg)
1796 flag_print_asm_name = 1;
1799 flag_dump_rtl_in_asm = 1;
1800 flag_print_asm_name = 1;
1803 graph_dump_format = vcg;
1806 rtl_dump_and_exit = 1;
1811 case 'D': /* These are handled by the preprocessor. */
1815 setup_core_dumping();
1820 if (!enable_rtl_dump_file (c))
1821 warning ("unrecognized gcc debugging option: %c", c);
1826 /* Indexed by enum debug_info_type. */
1827 const char *const debug_type_names[] =
1829 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff", "vms"
1832 /* Decode -m switches. */
1833 /* Decode the switch -mNAME. */
1836 set_target_switch (const char *name)
1839 int valid_target_option = 0;
1841 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
1842 if (!strcmp (target_switches[j].name, name))
1844 if (target_switches[j].value < 0)
1845 target_flags &= ~-target_switches[j].value;
1847 target_flags |= target_switches[j].value;
1850 if (target_switches[j].value < 0)
1851 target_flags_explicit |= -target_switches[j].value;
1853 target_flags_explicit |= target_switches[j].value;
1855 valid_target_option = 1;
1858 #ifdef TARGET_OPTIONS
1859 if (!valid_target_option)
1860 for (j = 0; j < ARRAY_SIZE (target_options); j++)
1862 int len = strlen (target_options[j].prefix);
1863 if (target_options[j].value)
1865 if (!strcmp (target_options[j].prefix, name))
1867 *target_options[j].variable = target_options[j].value;
1868 valid_target_option = 1;
1873 if (!strncmp (target_options[j].prefix, name, len))
1875 *target_options[j].variable = name + len;
1876 valid_target_option = 1;
1882 if (!valid_target_option)
1883 error ("invalid option `%s'", name);
1886 /* Print version information to FILE.
1887 Each line begins with INDENT (for the case where FILE is the
1888 assembler output file). */
1891 print_version (FILE *file, const char *indent)
1894 #define __VERSION__ "[?]"
1898 "%s%s%s version %s (%s)\n%s\tcompiled by GNU C version %s.\n"
1900 "%s%s%s version %s (%s) compiled by CC.\n"
1902 , indent, *indent != 0 ? " " : "",
1903 lang_hooks.name, version_string, TARGET_NAME,
1904 indent, __VERSION__);
1905 fnotice (file, "%s%sGGC heuristics: --param ggc-min-expand=%d --param ggc-min-heapsize=%d\n",
1906 indent, *indent != 0 ? " " : "",
1907 PARAM_VALUE (GGC_MIN_EXPAND), PARAM_VALUE (GGC_MIN_HEAPSIZE));
1910 /* Print an option value and return the adjusted position in the line.
1911 ??? We don't handle error returns from fprintf (disk full); presumably
1912 other code will catch a disk full though. */
1915 print_single_switch (FILE *file, int pos, int max,
1916 const char *indent, const char *sep, const char *term,
1917 const char *type, const char *name)
1919 /* The ultrix fprintf returns 0 on success, so compute the result we want
1920 here since we need it for the following test. */
1921 int len = strlen (sep) + strlen (type) + strlen (name);
1926 fprintf (file, "%s", term);
1931 fprintf (file, "%s", indent);
1932 pos = strlen (indent);
1934 fprintf (file, "%s%s%s", sep, type, name);
1939 /* Print active target switches to FILE.
1940 POS is the current cursor position and MAX is the size of a "line".
1941 Each line begins with INDENT and ends with TERM.
1942 Each switch is separated from the next by SEP. */
1945 print_switch_values (FILE *file, int pos, int max,
1946 const char *indent, const char *sep, const char *term)
1951 /* Fill in the -frandom-seed option, if the user didn't pass it, so
1952 that it can be printed below. This helps reproducibility. */
1955 /* Print the options as passed. */
1956 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
1957 _("options passed: "), "");
1959 for (p = &save_argv[1]; *p != NULL; p++)
1963 if (strcmp (*p, "-o") == 0)
1969 if (strcmp (*p, "-quiet") == 0)
1971 if (strcmp (*p, "-version") == 0)
1976 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
1979 fprintf (file, "%s", term);
1981 /* Print the -f and -m options that have been enabled.
1982 We don't handle language specific options but printing argv
1985 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
1986 _("options enabled: "), "");
1988 for (j = 0; j < ARRAY_SIZE (f_options); j++)
1989 if (*f_options[j].variable == f_options[j].on_value)
1990 pos = print_single_switch (file, pos, max, indent, sep, term,
1991 "-f", f_options[j].string);
1993 /* Print target specific options. */
1995 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
1996 if (target_switches[j].name[0] != '\0'
1997 && target_switches[j].value > 0
1998 && ((target_switches[j].value & target_flags)
1999 == target_switches[j].value))
2001 pos = print_single_switch (file, pos, max, indent, sep, term,
2002 "-m", target_switches[j].name);
2005 #ifdef TARGET_OPTIONS
2006 for (j = 0; j < ARRAY_SIZE (target_options); j++)
2007 if (*target_options[j].variable != NULL)
2010 sprintf (prefix, "-m%s", target_options[j].prefix);
2011 pos = print_single_switch (file, pos, max, indent, sep, term,
2012 prefix, *target_options[j].variable);
2016 fprintf (file, "%s", term);
2019 /* Open assembly code output file. Do this even if -fsyntax-only is
2020 on, because then the driver will have provided the name of a
2021 temporary file or bit bucket for us. NAME is the file specified on
2022 the command line, possibly NULL. */
2024 init_asm_output (const char *name)
2026 if (name == NULL && asm_file_name == 0)
2027 asm_out_file = stdout;
2030 if (asm_file_name == 0)
2032 int len = strlen (dump_base_name);
2033 char *dumpname = xmalloc (len + 6);
2034 memcpy (dumpname, dump_base_name, len + 1);
2035 strip_off_ending (dumpname, len);
2036 strcat (dumpname, ".s");
2037 asm_file_name = dumpname;
2039 if (!strcmp (asm_file_name, "-"))
2040 asm_out_file = stdout;
2042 asm_out_file = fopen (asm_file_name, "w+");
2043 if (asm_out_file == 0)
2044 fatal_error ("can't open %s for writing: %m", asm_file_name);
2047 #ifdef IO_BUFFER_SIZE
2048 setvbuf (asm_out_file, xmalloc (IO_BUFFER_SIZE),
2049 _IOFBF, IO_BUFFER_SIZE);
2052 if (!flag_syntax_only)
2054 targetm.asm_out.file_start ();
2056 #ifdef ASM_COMMENT_START
2057 if (flag_verbose_asm)
2059 /* Print the list of options in effect. */
2060 print_version (asm_out_file, ASM_COMMENT_START);
2061 print_switch_values (asm_out_file, 0, MAX_LINE,
2062 ASM_COMMENT_START, " ", "\n");
2063 /* Add a blank line here so it appears in assembler output but not
2065 fprintf (asm_out_file, "\n");
2071 /* Default version of get_pch_validity.
2072 By default, every flag difference is fatal; that will be mostly right for
2073 most targets, but completely right for very few. */
2076 default_get_pch_validity (size_t *len)
2078 #ifdef TARGET_OPTIONS
2083 *len = sizeof (target_flags) + 2;
2084 #ifdef TARGET_OPTIONS
2085 for (i = 0; i < ARRAY_SIZE (target_options); i++)
2088 if (*target_options[i].variable)
2089 *len += strlen (*target_options[i].variable);
2093 result = r = xmalloc (*len);
2097 memcpy (r, &target_flags, sizeof (target_flags));
2098 r += sizeof (target_flags);
2100 #ifdef TARGET_OPTIONS
2101 for (i = 0; i < ARRAY_SIZE (target_options); i++)
2103 const char *str = *target_options[i].variable;
2107 l = strlen (str) + 1;
2116 /* Default version of pch_valid_p. */
2119 default_pch_valid_p (const void *data_p, size_t len)
2121 const char *data = (const char *)data_p;
2122 const char *flag_that_differs = NULL;
2125 /* -fpic and -fpie also usually make a PCH invalid. */
2126 if (data[0] != flag_pic)
2127 return _("created and used with different settings of -fpic");
2128 if (data[1] != flag_pie)
2129 return _("created and used with different settings of -fpie");
2132 /* Check target_flags. */
2133 if (memcmp (data, &target_flags, sizeof (target_flags)) != 0)
2135 for (i = 0; i < ARRAY_SIZE (target_switches); i++)
2140 memcpy (&tf, data, sizeof (target_flags));
2142 bits = target_switches[i].value;
2145 if ((target_flags & bits) != (tf & bits))
2147 flag_that_differs = target_switches[i].name;
2153 data += sizeof (target_flags);
2154 len -= sizeof (target_flags);
2156 /* Check string options. */
2157 #ifdef TARGET_OPTIONS
2158 for (i = 0; i < ARRAY_SIZE (target_options); i++)
2160 const char *str = *target_options[i].variable;
2164 l = strlen (str) + 1;
2165 if (len < l || memcmp (data, str, l) != 0)
2167 flag_that_differs = target_options[i].prefix;
2180 asprintf (&r, _("created and used with differing settings of `-m%s'"),
2183 return _("out of memory");
2188 /* Default tree printer. Handles declarations only. */
2190 default_tree_printer (pretty_printer * pp, text_info *text)
2192 switch (*text->format_spec)
2198 tree t = va_arg (*text->args_ptr, tree);
2199 const char *n = DECL_NAME (t)
2200 ? lang_hooks.decl_printable_name (t, 2)
2211 /* Initialization of the front end environment, before command line
2212 options are parsed. Signal handlers, internationalization etc.
2213 ARGV0 is main's argv[0]. */
2215 general_init (const char *argv0)
2219 p = argv0 + strlen (argv0);
2220 while (p != argv0 && !IS_DIR_SEPARATOR (p[-1]))
2224 xmalloc_set_program_name (progname);
2228 gcc_init_libintl ();
2230 /* Initialize the diagnostics reporting machinery, so option parsing
2231 can give warnings and errors. */
2232 diagnostic_initialize (global_dc);
2233 /* Set a default printer. Language specific initializations will
2234 override it later. */
2235 pp_format_decoder (global_dc->printer) = &default_tree_printer;
2237 /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages. */
2239 signal (SIGSEGV, crash_signal);
2242 signal (SIGILL, crash_signal);
2245 signal (SIGBUS, crash_signal);
2248 signal (SIGABRT, crash_signal);
2250 #if defined SIGIOT && (!defined SIGABRT || SIGABRT != SIGIOT)
2251 signal (SIGIOT, crash_signal);
2254 signal (SIGFPE, crash_signal);
2257 /* Other host-specific signal setup. */
2258 (*host_hooks.extra_signals)();
2260 /* Initialize the garbage-collector, string pools and tree type hash
2264 linemap_init (&line_table);
2267 /* Initialize register usage now so switches may override. */
2270 /* Register the language-independent parameters. */
2271 add_params (lang_independent_params, LAST_PARAM);
2273 /* This must be done after add_params but before argument processing. */
2274 init_ggc_heuristics();
2275 init_tree_optimization_passes ();
2278 /* Process the options that have been parsed. */
2280 process_options (void)
2282 /* Allow the front end to perform consistency checks and do further
2283 initialization based on the command line options. This hook also
2284 sets the original filename if appropriate (e.g. foo.i -> foo.c)
2285 so we can correctly initialize debug output. */
2286 no_backend = lang_hooks.post_options (&main_input_filename);
2287 input_filename = main_input_filename;
2289 #ifdef OVERRIDE_OPTIONS
2290 /* Some machines may reject certain combinations of options. */
2294 if (flag_short_enums == 2)
2295 flag_short_enums = targetm.default_short_enums ();
2297 /* Set aux_base_name if not already set. */
2300 else if (main_input_filename)
2302 char *name = xstrdup (lbasename (main_input_filename));
2304 strip_off_ending (name, strlen (name));
2305 aux_base_name = name;
2308 aux_base_name = "gccaux";
2310 /* Set up the align_*_log variables, defaulting them to 1 if they
2311 were still unset. */
2312 if (align_loops <= 0) align_loops = 1;
2313 if (align_loops_max_skip > align_loops || !align_loops)
2314 align_loops_max_skip = align_loops - 1;
2315 align_loops_log = floor_log2 (align_loops * 2 - 1);
2316 if (align_jumps <= 0) align_jumps = 1;
2317 if (align_jumps_max_skip > align_jumps || !align_jumps)
2318 align_jumps_max_skip = align_jumps - 1;
2319 align_jumps_log = floor_log2 (align_jumps * 2 - 1);
2320 if (align_labels <= 0) align_labels = 1;
2321 align_labels_log = floor_log2 (align_labels * 2 - 1);
2322 if (align_labels_max_skip > align_labels || !align_labels)
2323 align_labels_max_skip = align_labels - 1;
2324 if (align_functions <= 0) align_functions = 1;
2325 align_functions_log = floor_log2 (align_functions * 2 - 1);
2327 /* Unrolling all loops implies that standard loop unrolling must also
2329 if (flag_unroll_all_loops)
2330 flag_unroll_loops = 1;
2332 if (flag_unroll_loops)
2334 flag_old_unroll_loops = 0;
2335 flag_old_unroll_all_loops = 0;
2338 if (flag_old_unroll_all_loops)
2339 flag_old_unroll_loops = 1;
2341 /* Old loop unrolling requires that strength_reduction be on also. Silently
2342 turn on strength reduction here if it isn't already on. Also, the loop
2343 unrolling code assumes that cse will be run after loop, so that must
2344 be turned on also. */
2345 if (flag_old_unroll_loops)
2347 flag_strength_reduce = 1;
2348 flag_rerun_cse_after_loop = 1;
2350 if (flag_unroll_loops || flag_peel_loops)
2351 flag_rerun_cse_after_loop = 1;
2353 if (flag_non_call_exceptions)
2354 flag_asynchronous_unwind_tables = 1;
2355 if (flag_asynchronous_unwind_tables)
2356 flag_unwind_tables = 1;
2358 /* Disable unit-at-a-time mode for frontends not supporting callgraph
2360 if (flag_unit_at_a_time && ! lang_hooks.callgraph.expand_function)
2361 flag_unit_at_a_time = 0;
2363 if (flag_value_profile_transformations)
2364 flag_profile_values = 1;
2366 /* Warn about options that are not supported on this machine. */
2367 #ifndef INSN_SCHEDULING
2368 if (flag_schedule_insns || flag_schedule_insns_after_reload)
2369 warning ("instruction scheduling not supported on this target machine");
2372 if (flag_delayed_branch)
2373 warning ("this target machine does not have delayed branches");
2376 if (flag_tree_based_profiling && flag_test_coverage)
2377 sorry ("test-coverage not yet implemented in trees.");
2378 if (flag_tree_based_profiling && flag_profile_values)
2379 sorry ("value-based profiling not yet implemented in trees.");
2381 user_label_prefix = USER_LABEL_PREFIX;
2382 if (flag_leading_underscore != -1)
2384 /* If the default prefix is more complicated than "" or "_",
2385 issue a warning and ignore this option. */
2386 if (user_label_prefix[0] == 0 ||
2387 (user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
2389 user_label_prefix = flag_leading_underscore ? "_" : "";
2392 warning ("-f%sleading-underscore not supported on this target machine",
2393 flag_leading_underscore ? "" : "no-");
2396 /* If we are in verbose mode, write out the version and maybe all the
2397 option flags in use. */
2400 print_version (stderr, "");
2402 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
2405 if (flag_syntax_only)
2407 write_symbols = NO_DEBUG;
2411 /* A lot of code assumes write_symbols == NO_DEBUG if the debugging
2413 if (debug_info_level == DINFO_LEVEL_NONE)
2414 write_symbols = NO_DEBUG;
2416 /* Now we know write_symbols, set up the debug hooks based on it.
2417 By default we do nothing for debug output. */
2418 if (PREFERRED_DEBUGGING_TYPE == NO_DEBUG)
2419 default_debug_hooks = &do_nothing_debug_hooks;
2420 #if defined(DBX_DEBUGGING_INFO)
2421 else if (PREFERRED_DEBUGGING_TYPE == DBX_DEBUG)
2422 default_debug_hooks = &dbx_debug_hooks;
2424 #if defined(XCOFF_DEBUGGING_INFO)
2425 else if (PREFERRED_DEBUGGING_TYPE == XCOFF_DEBUG)
2426 default_debug_hooks = &xcoff_debug_hooks;
2428 #ifdef SDB_DEBUGGING_INFO
2429 else if (PREFERRED_DEBUGGING_TYPE == SDB_DEBUG)
2430 default_debug_hooks = &sdb_debug_hooks;
2432 #ifdef DWARF2_DEBUGGING_INFO
2433 else if (PREFERRED_DEBUGGING_TYPE == DWARF2_DEBUG)
2434 default_debug_hooks = &dwarf2_debug_hooks;
2436 #ifdef VMS_DEBUGGING_INFO
2437 else if (PREFERRED_DEBUGGING_TYPE == VMS_DEBUG
2438 || PREFERRED_DEBUGGING_TYPE == VMS_AND_DWARF2_DEBUG)
2439 default_debug_hooks = &vmsdbg_debug_hooks;
2442 if (write_symbols == NO_DEBUG)
2443 debug_hooks = &do_nothing_debug_hooks;
2444 #if defined(DBX_DEBUGGING_INFO)
2445 else if (write_symbols == DBX_DEBUG)
2446 debug_hooks = &dbx_debug_hooks;
2448 #if defined(XCOFF_DEBUGGING_INFO)
2449 else if (write_symbols == XCOFF_DEBUG)
2450 debug_hooks = &xcoff_debug_hooks;
2452 #ifdef SDB_DEBUGGING_INFO
2453 else if (write_symbols == SDB_DEBUG)
2454 debug_hooks = &sdb_debug_hooks;
2456 #ifdef DWARF2_DEBUGGING_INFO
2457 else if (write_symbols == DWARF2_DEBUG)
2458 debug_hooks = &dwarf2_debug_hooks;
2460 #ifdef VMS_DEBUGGING_INFO
2461 else if (write_symbols == VMS_DEBUG || write_symbols == VMS_AND_DWARF2_DEBUG)
2462 debug_hooks = &vmsdbg_debug_hooks;
2465 error ("target system does not support the \"%s\" debug format",
2466 debug_type_names[write_symbols]);
2468 /* Now we know which debug output will be used so we can set
2469 flag_var_tracking, flag_rename_registers and flag_web if the user has
2470 not specified them. */
2471 if (debug_info_level < DINFO_LEVEL_NORMAL
2472 || debug_hooks->var_location == do_nothing_debug_hooks.var_location)
2474 if (flag_var_tracking == 1)
2476 if (debug_info_level < DINFO_LEVEL_NORMAL)
2477 warning ("variable tracking requested, but useless unless "
2478 "producing debug info");
2480 warning ("variable tracking requested, but not supported "
2481 "by this debug format");
2483 flag_var_tracking = 0;
2486 if (flag_rename_registers == AUTODETECT_FLAG_VAR_TRACKING)
2487 flag_rename_registers = default_debug_hooks->var_location
2488 != do_nothing_debug_hooks.var_location;
2490 if (flag_web == AUTODETECT_FLAG_VAR_TRACKING)
2491 flag_web = optimize >= 2 && (default_debug_hooks->var_location
2492 != do_nothing_debug_hooks.var_location);
2494 if (flag_var_tracking == AUTODETECT_FLAG_VAR_TRACKING)
2495 flag_var_tracking = optimize >= 1;
2497 /* If auxiliary info generation is desired, open the output file.
2498 This goes in the same directory as the source file--unlike
2499 all the other output files. */
2500 if (flag_gen_aux_info)
2502 aux_info_file = fopen (aux_info_file_name, "w");
2503 if (aux_info_file == 0)
2504 fatal_error ("can't open %s: %m", aux_info_file_name);
2507 if (! targetm.have_named_sections)
2509 if (flag_function_sections)
2511 warning ("-ffunction-sections not supported for this target");
2512 flag_function_sections = 0;
2514 if (flag_data_sections)
2516 warning ("-fdata-sections not supported for this target");
2517 flag_data_sections = 0;
2521 if (flag_function_sections && profile_flag)
2523 warning ("-ffunction-sections disabled; it makes profiling impossible");
2524 flag_function_sections = 0;
2527 #ifndef HAVE_prefetch
2528 if (flag_prefetch_loop_arrays)
2530 warning ("-fprefetch-loop-arrays not supported for this target");
2531 flag_prefetch_loop_arrays = 0;
2534 if (flag_prefetch_loop_arrays && !HAVE_prefetch)
2536 warning ("-fprefetch-loop-arrays not supported for this target (try -march switches)");
2537 flag_prefetch_loop_arrays = 0;
2541 /* This combination of options isn't handled for i386 targets and doesn't
2542 make much sense anyway, so don't allow it. */
2543 if (flag_prefetch_loop_arrays && optimize_size)
2545 warning ("-fprefetch-loop-arrays is not supported with -Os");
2546 flag_prefetch_loop_arrays = 0;
2549 #ifndef OBJECT_FORMAT_ELF
2550 if (flag_function_sections && write_symbols != NO_DEBUG)
2551 warning ("-ffunction-sections may affect debugging on some targets");
2554 /* The presence of IEEE signaling NaNs, implies all math can trap. */
2555 if (flag_signaling_nans)
2556 flag_trapping_math = 1;
2559 /* Initialize the compiler back end. */
2563 init_adjust_machine_modes ();
2565 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2566 || debug_info_level == DINFO_LEVEL_VERBOSE
2567 #ifdef VMS_DEBUGGING_INFO
2568 /* Enable line number info for traceback. */
2569 || debug_info_level > DINFO_LEVEL_NONE
2571 || flag_test_coverage
2572 || warn_notreached);
2575 init_fake_stack_mems ();
2579 init_function_once ();
2580 init_varasm_once ();
2582 /* The following initialization functions need to generate rtl, so
2583 provide a dummy function context for them. */
2584 init_dummy_function_start ();
2586 if (flag_caller_saves)
2587 init_caller_save ();
2588 expand_dummy_function_end ();
2591 /* Language-dependent initialization. Returns nonzero on success. */
2593 lang_dependent_init (const char *name)
2595 if (dump_base_name == 0)
2596 dump_base_name = name ? name : "gccdump";
2598 /* Other front-end initialization. */
2599 if (lang_hooks.init () == 0)
2602 init_asm_output (name);
2604 /* These create various _DECL nodes, so need to be called after the
2605 front end is initialized. */
2608 init_optimization_passes ();
2610 /* The following initialization functions need to generate rtl, so
2611 provide a dummy function context for them. */
2612 init_dummy_function_start ();
2614 expand_dummy_function_end ();
2616 /* If dbx symbol table desired, initialize writing it and output the
2617 predefined types. */
2618 timevar_push (TV_SYMOUT);
2620 #ifdef DWARF2_UNWIND_INFO
2621 if (dwarf2out_do_frame ())
2622 dwarf2out_frame_init ();
2625 /* Now we have the correct original filename, we can initialize
2627 (*debug_hooks->init) (name);
2629 timevar_pop (TV_SYMOUT);
2634 /* Clean up: close opened files, etc. */
2639 /* Close the dump files. */
2640 if (flag_gen_aux_info)
2642 fclose (aux_info_file);
2644 unlink (aux_info_file_name);
2647 /* Close non-debugging input and output files. Take special care to note
2648 whether fclose returns an error, since the pages might still be on the
2649 buffer chain while the file is open. */
2653 if (ferror (asm_out_file) != 0)
2654 fatal_error ("error writing to %s: %m", asm_file_name);
2655 if (fclose (asm_out_file) != 0)
2656 fatal_error ("error closing %s: %m", asm_file_name);
2659 finish_optimization_passes ();
2663 ggc_print_statistics ();
2664 stringpool_statistics ();
2665 dump_tree_statistics ();
2666 dump_rtx_statistics ();
2667 dump_varray_statistics ();
2668 dump_alloc_pool_statistics ();
2669 dump_ggc_loc_statistics ();
2672 /* Free up memory for the benefit of leak detectors. */
2675 /* Language-specific end of compilation actions. */
2676 lang_hooks.finish ();
2679 /* Initialize the compiler, and compile the input file. */
2683 /* Initialize timing first. The C front ends read the main file in
2684 the post_options hook, and C++ does file timings. */
2685 if (time_report || !quiet_flag || flag_detailed_statistics)
2687 timevar_start (TV_TOTAL);
2691 /* Don't do any more if an error has already occurred. */
2694 /* Set up the back-end if requested. */
2698 /* Language-dependent initialization. Returns true on success. */
2699 if (lang_dependent_init (main_input_filename))
2705 /* Stop timing and print the times. */
2706 timevar_stop (TV_TOTAL);
2707 timevar_print (stderr);
2710 /* Entry point of cc1, cc1plus, jc1, f771, etc.
2711 Exit code is FATAL_EXIT_CODE if can't open files or if there were
2712 any errors, or SUCCESS_EXIT_CODE if compilation succeeded.
2714 It is not safe to call this function more than once. */
2717 toplev_main (unsigned int argc, const char **argv)
2721 /* Initialization of GCC's environment, and diagnostics. */
2722 general_init (argv[0]);
2724 /* Parse the options and do minimal processing; basically just
2725 enough to default flags appropriately. */
2726 decode_options (argc, argv);
2730 /* Exit early if we can (e.g. -help). */
2731 if (!exit_after_options)
2734 if (errorcount || sorrycount)
2735 return (FATAL_EXIT_CODE);
2737 return (SUCCESS_EXIT_CODE);