1 /* Top level of GCC compilers (cc1, cc1plus, etc.)
2 Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 /* This is the top level of cc1/c++.
23 It parses command args, opens files, invokes the various passes
24 in the proper order, and counts the time used by each.
25 Error messages and low-level interface to malloc also handled here. */
28 #undef FLOAT /* This is for hpux. They should change hpux. */
29 #undef FFS /* Some systems define this in param.h. */
31 #include "coretypes.h"
35 #ifdef HAVE_SYS_RESOURCE_H
36 # include <sys/resource.h>
39 #ifdef HAVE_SYS_TIMES_H
40 # include <sys/times.h>
48 #include "insn-attr.h"
49 #include "insn-config.h"
50 #include "insn-flags.h"
51 #include "hard-reg-set.h"
58 #include "basic-block.h"
65 #include "diagnostic.h"
68 #include "dwarf2asm.h"
69 #include "integrate.h"
73 #include "langhooks.h"
74 #include "cfglayout.h"
76 #include "hosthooks.h"
80 #include "value-prof.h"
82 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
83 #include "dwarf2out.h"
86 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
90 #ifdef SDB_DEBUGGING_INFO
94 #ifdef XCOFF_DEBUGGING_INFO
95 #include "xcoffout.h" /* Needed for external data
96 declarations for e.g. AIX 4.x. */
99 /* Carry information from ASM_DECLARE_OBJECT_NAME
100 to ASM_FINISH_DECLARE_OBJECT. */
102 extern int size_directive_output;
103 extern tree last_assemble_variable_decl;
105 extern void reg_alloc (void);
107 static void general_init (const char *);
108 static void do_compile (void);
109 static void process_options (void);
110 static void backend_init (void);
111 static int lang_dependent_init (const char *);
112 static void init_asm_output (const char *);
113 static void finalize (void);
115 static void crash_signal (int) ATTRIBUTE_NORETURN;
116 static void setup_core_dumping (void);
117 static void compile_file (void);
119 static int print_single_switch (FILE *, int, int, const char *,
120 const char *, const char *,
121 const char *, const char *);
122 static void print_switch_values (FILE *, int, int, const char *,
123 const char *, const char *);
125 /* Rest of compilation helper functions. */
126 static bool rest_of_handle_inlining (tree);
127 static void rest_of_handle_cse (tree, rtx);
128 static void rest_of_handle_cse2 (tree, rtx);
129 static void rest_of_handle_gcse (tree, rtx);
130 static void rest_of_handle_life (tree, rtx);
131 static void rest_of_handle_loop_optimize (tree, rtx);
132 static void rest_of_handle_loop2 (tree, rtx);
133 static void rest_of_handle_jump_bypass (tree, rtx);
134 static void rest_of_handle_sibling_calls (rtx);
135 static void rest_of_handle_null_pointer (tree, rtx);
136 static void rest_of_handle_addressof (tree, rtx);
137 static void rest_of_handle_cfg (tree, rtx);
138 static void rest_of_handle_branch_prob (tree, rtx);
139 static void rest_of_handle_value_profile_transformations (tree, rtx);
140 static void rest_of_handle_if_conversion (tree, rtx);
141 static void rest_of_handle_if_after_combine (tree, rtx);
142 static void rest_of_handle_tracer (tree, rtx);
143 static void rest_of_handle_combine (tree, rtx);
144 static void rest_of_handle_regmove (tree, rtx);
145 #ifdef INSN_SCHEDULING
146 static void rest_of_handle_sched (tree, rtx);
147 static void rest_of_handle_sched2 (tree, rtx);
149 static bool rest_of_handle_new_regalloc (tree, rtx);
150 static bool rest_of_handle_old_regalloc (tree, rtx);
151 static void rest_of_handle_regrename (tree, rtx);
152 static void rest_of_handle_reorder_blocks (tree, rtx);
154 static void rest_of_handle_stack_regs (tree, rtx);
156 static void rest_of_handle_machine_reorg (tree, rtx);
158 static void rest_of_handle_delay_slots (tree, rtx);
160 static void rest_of_handle_final (tree, rtx);
162 /* Nonzero to dump debug info whilst parsing (-dy option). */
163 static int set_yydebug;
165 /* True if we don't need a backend (e.g. preprocessing only). */
166 static bool no_backend;
168 /* Length of line when printing switch values. */
171 /* Name of program invoked, sans directories. */
173 const char *progname;
175 /* Copy of argument vector to toplev_main. */
176 static const char **save_argv;
178 /* Name of top-level original source file (what was input to cpp).
179 This comes from the #-command at the beginning of the actual input.
180 If there isn't any there, then this is the cc1 input file name. */
182 const char *main_input_filename;
184 /* Current position in real source file. */
186 location_t input_location;
188 /* Nonzero if it is unsafe to create any new pseudo registers. */
191 /* Stack of currently pending input files. */
193 struct file_stack *input_file_stack;
195 /* Incremented on each change to input_file_stack. */
196 int input_file_stack_tick;
198 /* Name to use as base of names for dump output files. */
200 const char *dump_base_name;
202 /* Name to use as a base for auxiliary output files. */
204 const char *aux_base_name;
206 /* Format to use to print dumpfile index value */
207 #ifndef DUMPFILE_FORMAT
208 #define DUMPFILE_FORMAT ".%02d."
211 /* Bit flags that specify the machine subtype we are compiling for.
212 Bits are tested using macros TARGET_... defined in the tm.h file
213 and set by `-m...' switches. Must be defined in rtlanal.c. */
215 extern int target_flags;
217 /* A mask of target_flags that includes bit X if X was set or cleared
218 on the command line. */
220 int target_flags_explicit;
222 /* Debug hooks - dependent upon command line options. */
224 const struct gcc_debug_hooks *debug_hooks;
226 /* Describes a dump file. */
228 struct dump_file_info
230 /* The unique extension to apply, e.g. ".jump". */
231 const char *const extension;
233 /* The -d<c> character that enables this dump file. */
234 char const debug_switch;
236 /* True if there is a corresponding graph dump file. */
237 char const graph_dump_p;
239 /* True if the user selected this dump. */
242 /* True if the files have been initialized (ie truncated). */
246 /* Enumerate the extant dump files. */
282 DFI_branch_target_load,
290 /* Describes all the dump files. Should be kept in order of the
291 pass and in sync with dump_file_index above.
293 Remaining -d letters:
299 static struct dump_file_info dump_file[DFI_MAX] =
301 { "cgraph", 'U', 0, 0, 0 },
302 { "rtl", 'r', 0, 0, 0 },
303 { "sibling", 'i', 0, 0, 0 },
304 { "eh", 'h', 0, 0, 0 },
305 { "jump", 'j', 0, 0, 0 },
306 { "null", 'u', 0, 0, 0 },
307 { "cse", 's', 0, 0, 0 },
308 { "addressof", 'F', 0, 0, 0 },
309 { "gcse", 'G', 1, 0, 0 },
310 { "loop", 'L', 1, 0, 0 },
311 { "bypass", 'G', 1, 0, 0 }, /* Yes, duplicate enable switch. */
312 { "cfg", 'f', 1, 0, 0 },
313 { "bp", 'b', 1, 0, 0 },
314 { "vpt", 'V', 1, 0, 0 },
315 { "ce1", 'C', 1, 0, 0 },
316 { "tracer", 'T', 1, 0, 0 },
317 { "loop2", 'L', 1, 0, 0 },
318 { "web", 'Z', 0, 0, 0 },
319 { "cse2", 't', 1, 0, 0 },
320 { "life", 'f', 1, 0, 0 }, /* Yes, duplicate enable switch. */
321 { "combine", 'c', 1, 0, 0 },
322 { "ce2", 'C', 1, 0, 0 },
323 { "regmove", 'N', 1, 0, 0 },
324 { "sched", 'S', 1, 0, 0 },
325 { "lreg", 'l', 1, 0, 0 },
326 { "greg", 'g', 1, 0, 0 },
327 { "postreload", 'o', 1, 0, 0 },
328 { "flow2", 'w', 1, 0, 0 },
329 { "peephole2", 'z', 1, 0, 0 },
330 { "rnreg", 'n', 1, 0, 0 },
331 { "bbro", 'B', 1, 0, 0 },
332 { "ce3", 'E', 1, 0, 0 },
333 { "btl", 'd', 1, 0, 0 }, /* Yes, duplicate enable switch. */
334 { "sched2", 'R', 1, 0, 0 },
335 { "stack", 'k', 1, 0, 0 },
336 { "mach", 'M', 1, 0, 0 },
337 { "dbr", 'd', 0, 0, 0 },
340 static int open_dump_file (enum dump_file_index, tree);
341 static void close_dump_file (enum dump_file_index,
342 void (*) (FILE *, rtx), rtx);
344 /* Other flags saying which kinds of debugging dump have been requested. */
346 int rtl_dump_and_exit;
347 int flag_print_asm_name;
348 enum graph_dump_types graph_dump_format;
350 /* Name for output file of assembly code, specified with -o. */
352 const char *asm_file_name;
354 /* Nonzero means do optimizations. -O.
355 Particular numeric values stand for particular amounts of optimization;
356 thus, -O2 stores 2 here. However, the optimizations beyond the basic
357 ones are not controlled directly by this variable. Instead, they are
358 controlled by individual `flag_...' variables that are defaulted
359 based on this variable. */
363 /* Nonzero means optimize for size. -Os.
364 The only valid values are zero and nonzero. When optimize_size is
365 nonzero, optimize defaults to 2, but certain individual code
366 bloating optimizations are disabled. */
368 int optimize_size = 0;
370 /* The FUNCTION_DECL for the function currently being compiled,
371 or 0 if between functions. */
372 tree current_function_decl;
374 /* Set to the FUNC_BEGIN label of the current function, or NULL_TREE
376 tree current_function_func_begin_label;
378 /* Nonzero if doing dwarf2 duplicate elimination. */
380 int flag_eliminate_dwarf2_dups = 0;
382 /* Nonzero if doing unused type elimination. */
384 int flag_eliminate_unused_debug_types = 1;
386 /* Nonzero means emit debugging information only for symbols which are used. */
387 int flag_debug_only_used_symbols = 0;
389 /* Nonzero if generating code to do profiling. */
391 int profile_flag = 0;
393 /* Nonzero if generating code to profile program flow graph arcs. */
395 int profile_arc_flag = 0;
397 /* Nonzero if value histograms should be measured. */
399 int flag_profile_values = 0;
401 /* Nonzero if value histograms should be used to optimize code. */
402 int flag_value_profile_transformations = 0;
404 /* Nonzero if generating info for gcov to calculate line test coverage. */
406 int flag_test_coverage = 0;
408 /* Nonzero indicates that branch taken probabilities should be calculated. */
410 int flag_branch_probabilities = 0;
412 /* Nonzero if basic blocks should be reordered. */
414 int flag_reorder_blocks = 0;
416 /* Nonzero if functions should be reordered. */
418 int flag_reorder_functions = 0;
420 /* Nonzero if registers should be renamed. */
422 int flag_rename_registers = 0;
423 int flag_cprop_registers = 0;
425 /* Nonzero for -pedantic switch: warn about anything
426 that standard spec forbids. */
430 /* Temporarily suppress certain warnings.
431 This is set while reading code from a system header file. */
433 int in_system_header = 0;
435 /* Don't print functions as they are compiled. -quiet. */
439 /* Print times taken by the various passes. -ftime-report. */
443 /* Print memory still in use at end of compilation (which may have little
444 to do with peak memory consumption). -fmem-report. */
448 /* Nonzero means to collect statistics which might be expensive
449 and to print them when we are done. */
450 int flag_detailed_statistics = 0;
452 /* A random sequence of characters, unless overridden by user. */
453 const char *flag_random_seed;
455 /* A local time stamp derived from the time of compilation. It will be
456 zero if the system cannot provide a time. It will be -1u, if the
457 user has specified a particular random seed. */
462 /* Nonzero means `char' should be signed. */
464 int flag_signed_char;
466 /* Nonzero means give an enum type only as many bytes as it needs. */
468 int flag_short_enums;
470 /* Nonzero for -fcaller-saves: allocate values in regs that need to
471 be saved across function calls, if that produces overall better code.
472 Optional now, so people can test it. */
474 #ifdef DEFAULT_CALLER_SAVES
475 int flag_caller_saves = 1;
477 int flag_caller_saves = 0;
480 /* Nonzero if structures and unions should be returned in memory.
482 This should only be defined if compatibility with another compiler or
483 with an ABI is needed, because it results in slower code. */
485 #ifndef DEFAULT_PCC_STRUCT_RETURN
486 #define DEFAULT_PCC_STRUCT_RETURN 1
489 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
491 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
493 /* Nonzero for -fforce-mem: load memory value into a register
494 before arithmetic on it. This makes better cse but slower compilation. */
496 int flag_force_mem = 0;
498 /* Nonzero for -fforce-addr: load memory address into a register before
499 reference to memory. This makes better cse but slower compilation. */
501 int flag_force_addr = 0;
503 /* Nonzero for -fdefer-pop: don't pop args after each function call;
504 instead save them up to pop many calls' args with one insns. */
506 int flag_defer_pop = 0;
508 /* Nonzero for -ffloat-store: don't allocate floats and doubles
509 in extended-precision registers. */
511 int flag_float_store = 0;
513 /* Nonzero for -fcse-follow-jumps:
514 have cse follow jumps to do a more extensive job. */
516 int flag_cse_follow_jumps;
518 /* Nonzero for -fcse-skip-blocks:
519 have cse follow a branch around a block. */
520 int flag_cse_skip_blocks;
522 /* Nonzero for -fexpensive-optimizations:
523 perform miscellaneous relatively-expensive optimizations. */
524 int flag_expensive_optimizations;
526 /* Nonzero for -fthread-jumps:
527 have jump optimize output of loop. */
529 int flag_thread_jumps;
531 /* Nonzero enables strength-reduction in loop.c. */
533 int flag_strength_reduce = 0;
535 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
536 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
537 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
540 int flag_old_unroll_loops;
542 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
543 This is generally not a win. */
545 int flag_old_unroll_all_loops;
547 /* Enables unrolling of simple loops in loop-unroll.c. */
548 int flag_unroll_loops;
550 /* Enables unrolling of all loops in loop-unroll.c. */
551 int flag_unroll_all_loops;
553 /* Nonzero enables loop peeling. */
556 /* Nonzero enables loop unswitching. */
557 int flag_unswitch_loops;
559 /* Nonzero enables prefetch optimizations for arrays in loops. */
561 int flag_prefetch_loop_arrays;
563 /* Nonzero forces all invariant computations in loops to be moved
566 int flag_move_all_movables = 0;
568 /* Nonzero forces all general induction variables in loops to be
571 int flag_reduce_all_givs = 0;
573 /* Nonzero to perform full register move optimization passes. This is the
576 int flag_regmove = 0;
578 /* Nonzero for -fwritable-strings:
579 store string constants in data segment and don't uniquize them. */
581 int flag_writable_strings = 0;
583 /* Nonzero means don't put addresses of constant functions in registers.
584 Used for compiling the Unix kernel, where strange substitutions are
585 done on the assembly output. */
587 int flag_no_function_cse = 0;
589 /* Nonzero for -fomit-frame-pointer:
590 don't make a frame pointer in simple functions that don't require one. */
592 int flag_omit_frame_pointer = 0;
594 /* Nonzero means place each function into its own section on those platforms
595 which support arbitrary section names and unlimited numbers of sections. */
597 int flag_function_sections = 0;
599 /* ... and similar for data. */
601 int flag_data_sections = 0;
603 /* Nonzero to inhibit use of define_optimization peephole opts. */
605 int flag_no_peephole = 0;
607 /* Nonzero allows GCC to optimize sibling and tail recursive calls. */
609 int flag_optimize_sibling_calls = 0;
611 /* Nonzero means the front end generally wants `errno' maintained by math
612 operations, like built-in SQRT. */
614 int flag_errno_math = 1;
616 /* Nonzero means that unsafe floating-point math optimizations are allowed
617 for the sake of speed. IEEE compliance is not guaranteed, and operations
618 are allowed to assume that their arguments and results are "normal"
619 (e.g., nonnegative for SQRT). */
621 int flag_unsafe_math_optimizations = 0;
623 /* Nonzero means that no NaNs or +-Infs are expected. */
625 int flag_finite_math_only = 0;
627 /* Zero means that floating-point math operations cannot generate a
628 (user-visible) trap. This is the case, for example, in nonstop
629 IEEE 754 arithmetic. Trapping conditions include division by zero,
630 overflow, underflow, invalid and inexact, but does not include
631 operations on signaling NaNs (see below). */
633 int flag_trapping_math = 1;
635 /* Nonzero means disable transformations that assume default floating
636 point rounding behavior. */
638 int flag_rounding_math = 0;
640 /* Nonzero means disable transformations observable by signaling NaNs.
641 This option implies that any operation on an IEEE signaling NaN can
642 generate a (user-visible) trap. */
644 int flag_signaling_nans = 0;
646 /* 0 means straightforward implementation of complex divide acceptable.
647 1 means wide ranges of inputs must work for complex divide.
648 2 means C99-like requirements for complex divide (not yet implemented). */
650 int flag_complex_divide_method = 0;
652 /* Nonzero means just do syntax checking; don't output anything. */
654 int flag_syntax_only = 0;
656 /* Nonzero means performs web construction pass. */
660 /* Nonzero means perform loop optimizer. */
662 int flag_loop_optimize;
664 /* Nonzero means perform crossjumping. */
666 int flag_crossjumping;
668 /* Nonzero means perform if conversion. */
670 int flag_if_conversion;
672 /* Nonzero means perform if conversion after reload. */
674 int flag_if_conversion2;
676 /* Nonzero means to use global dataflow analysis to eliminate
677 useless null pointer tests. */
679 int flag_delete_null_pointer_checks;
681 /* Nonzero means perform global CSE. */
685 /* Nonzero means to do the enhanced load motion during gcse, which trys
686 to hoist loads by not killing them when a store to the same location
689 int flag_gcse_lm = 1;
691 /* Nonzero means to perform store motion after gcse, which will try to
692 move stores closer to the exit block. Its not very effective without
695 int flag_gcse_sm = 1;
697 /* Nonzero if we want to perfrom redundant load after store elimination
700 int flag_gcse_las = 1;
702 /* Perform target register optimization before prologue / epilogue
705 int flag_branch_target_load_optimize = 0;
707 /* Perform target register optimization after prologue / epilogue
708 threading and jump2. */
710 int flag_branch_target_load_optimize2 = 0;
712 /* Nonzero means to rerun cse after loop optimization. This increases
713 compilation time about 20% and picks up a few more common expressions. */
715 int flag_rerun_cse_after_loop;
717 /* Nonzero means to run loop optimizations twice. */
719 int flag_rerun_loop_opt;
721 /* Nonzero for -finline-functions: ok to inline functions that look like
722 good inline candidates. */
724 int flag_inline_functions;
726 /* Nonzero for -fkeep-inline-functions: even if we make a function
727 go inline everywhere, keep its definition around for debugging
730 int flag_keep_inline_functions;
732 /* Nonzero means that functions will not be inlined. */
734 int flag_no_inline = 2;
736 /* Nonzero means that we don't want inlining by virtue of -fno-inline,
737 not just because the tree inliner turned us off. */
739 int flag_really_no_inline = 2;
741 /* Nonzero means that we should emit static const variables
742 regardless of whether or not optimization is turned on. */
744 int flag_keep_static_consts = 1;
746 /* Nonzero means we should be saving declaration info into a .X file. */
748 int flag_gen_aux_info = 0;
750 /* Specified name of aux-info file. */
752 const char *aux_info_file_name;
754 /* Nonzero means make the text shared if supported. */
756 int flag_shared_data;
758 /* Nonzero means schedule into delayed branch slots if supported. */
760 int flag_delayed_branch;
762 /* Nonzero if we are compiling pure (sharable) code.
763 Value is 1 if we are doing "small" pic; value is 2 if we're doing
768 /* Nonzero if we are compiling position independent code for executable.
769 The value is 1 if we are doing "small" pic; value is 2 if we're doing
774 /* Nonzero if we are compiling code for a shared library, zero for
779 /* Set to the default thread-local storage (tls) model to use. */
781 enum tls_model flag_tls_default = TLS_MODEL_GLOBAL_DYNAMIC;
783 /* Nonzero means generate extra code for exception handling and enable
784 exception handling. */
788 /* Nonzero means generate frame unwind info table when supported. */
790 int flag_unwind_tables = 0;
792 /* Nonzero means generate frame unwind info table exact at each insn
795 int flag_asynchronous_unwind_tables = 0;
797 /* Nonzero means don't place uninitialized global data in common storage
802 /* Nonzero means change certain warnings into errors.
803 Usually these are warnings about failure to conform to some standard. */
805 int flag_pedantic_errors = 0;
807 /* flag_schedule_insns means schedule insns within basic blocks (before
809 flag_schedule_insns_after_reload means schedule insns after
812 int flag_schedule_insns = 0;
813 int flag_schedule_insns_after_reload = 0;
815 /* When flag_schedule_insns_after_reload is set, use EBB scheduler. */
816 int flag_sched2_use_superblocks = 0;
818 /* When flag_schedule_insns_after_reload is set, construct traces and EBB
820 int flag_sched2_use_traces = 0;
822 /* The following flags have effect only for scheduling before register
825 flag_schedule_interblock means schedule insns across basic blocks.
826 flag_schedule_speculative means allow speculative motion of non-load insns.
827 flag_schedule_speculative_load means allow speculative motion of some
829 flag_schedule_speculative_load_dangerous allows speculative motion of more
832 int flag_schedule_interblock = 1;
833 int flag_schedule_speculative = 1;
834 int flag_schedule_speculative_load = 0;
835 int flag_schedule_speculative_load_dangerous = 0;
837 /* The following flags have an effect during scheduling after register
840 flag_sched_stalled_insns means that insns can be moved prematurely from the queue
841 of stalled insns into the ready list.
843 flag_sched_stalled_insns_dep controls how many insn groups will be examined
844 for a dependency on a stalled insn that is candidate for premature removal
845 from the queue of stalled insns into the ready list (has an effect only if
846 the flag 'sched_stalled_insns' is set). */
848 int flag_sched_stalled_insns = 0;
849 int flag_sched_stalled_insns_dep = 1;
851 int flag_single_precision_constant;
853 /* flag_branch_on_count_reg means try to replace add-1,compare,branch tupple
854 by a cheaper branch on a count register. */
855 int flag_branch_on_count_reg = 1;
857 /* -finhibit-size-directive inhibits output of .size for ELF.
858 This is used only for compiling crtstuff.c,
859 and it may be extended to other effects
860 needed for crtstuff.c on other systems. */
861 int flag_inhibit_size_directive = 0;
863 /* -fverbose-asm causes extra commentary information to be produced in
864 the generated assembly code (to make it more readable). This option
865 is generally only of use to those who actually need to read the
866 generated assembly code (perhaps while debugging the compiler itself).
867 -fno-verbose-asm, the default, causes the extra information
868 to be omitted and is useful when comparing two assembler files. */
870 int flag_verbose_asm = 0;
872 /* -dA causes debug commentary information to be produced in
873 the generated assembly code (to make it more readable). This option
874 is generally only of use to those who actually need to read the
875 generated assembly code (perhaps while debugging the compiler itself).
876 Currently, this switch is only used by dwarfout.c; however, it is intended
877 to be a catchall for printing debug information in the assembler file. */
879 int flag_debug_asm = 0;
881 /* -dP causes the rtl to be emitted as a comment in assembly. */
883 int flag_dump_rtl_in_asm = 0;
885 /* Nonzero means put zero initialized data in the bss section. */
886 int flag_zero_initialized_in_bss = 1;
888 /* Tag all structures with __attribute__(packed). */
889 int flag_pack_struct = 0;
891 /* Emit code to check for stack overflow; also may cause large objects
892 to be allocated dynamically. */
893 int flag_stack_check;
895 /* When non-NULL, indicates that whenever space is allocated on the
896 stack, the resulting stack pointer must not pass this
897 address---that is, for stacks that grow downward, the stack pointer
898 must always be greater than or equal to this address; for stacks
899 that grow upward, the stack pointer must be less than this address.
900 At present, the rtx may be either a REG or a SYMBOL_REF, although
901 the support provided depends on the backend. */
904 /* 0 if pointer arguments may alias each other. True in C.
905 1 if pointer arguments may not alias each other but may alias
907 2 if pointer arguments may not alias each other and may not
908 alias global variables. True in Fortran.
909 This defaults to 0 for C. */
910 int flag_argument_noalias = 0;
912 /* Nonzero if we should do (language-dependent) alias analysis.
913 Typically, this analysis will assume that expressions of certain
914 types do not alias expressions of certain other types. Only used
915 if alias analysis (in general) is enabled. */
916 int flag_strict_aliasing = 0;
918 /* Instrument functions with calls at entry and exit, for profiling. */
919 int flag_instrument_function_entry_exit = 0;
921 /* Nonzero means ignore `#ident' directives. 0 means handle them.
922 On SVR4 targets, it also controls whether or not to emit a
923 string identifying the compiler. */
925 int flag_no_ident = 0;
927 /* This will perform a peephole pass before sched2. */
928 int flag_peephole2 = 0;
930 /* This will try to guess branch probabilities. */
931 int flag_guess_branch_prob = 0;
933 /* -fcheck-bounds causes gcc to generate array bounds checks.
934 For C, C++, ObjC: defaults to off.
935 For Java: defaults to on.
936 For Fortran: defaults to off. */
937 int flag_bounds_check = 0;
939 /* This will attempt to merge constant section constants, if 1 only
940 string constants and constants from constant pool, if 2 also constant
942 int flag_merge_constants = 1;
944 /* If one, renumber instruction UIDs to reduce the number of
945 unused UIDs if there are a lot of instructions. If greater than
946 one, unconditionally renumber instruction UIDs. */
947 int flag_renumber_insns = 1;
949 /* If nonzero, use the graph coloring register allocator. */
950 int flag_new_regalloc = 0;
952 /* Nonzero if we perform superblock formation. */
956 /* Nonzero if we perform whole unit at a time compilation. */
958 int flag_unit_at_a_time = 0;
960 /* Values of the -falign-* flags: how much to align labels in code.
961 0 means `use default', 1 means `don't align'.
962 For each variable, there is an _log variant which is the power
963 of two not less than the variable, for .align output. */
967 int align_loops_max_skip;
970 int align_jumps_max_skip;
972 int align_labels_log;
973 int align_labels_max_skip;
975 int align_functions_log;
977 /* Like align_functions_log above, but used by front-ends to force the
978 minimum function alignment. Zero means no alignment is forced. */
979 int force_align_functions_log;
983 const char *const string;
987 lang_independent_options;
989 /* Nonzero if signed arithmetic overflow should trap. */
992 /* Nonzero if signed arithmetic overflow should wrap around. */
995 /* Nonzero if subexpressions must be evaluated from left-to-right. */
996 int flag_evaluation_order = 0;
998 /* Add or remove a leading underscore from user symbols. */
999 int flag_leading_underscore = -1;
1001 /* The user symbol prefix after having resolved same. */
1002 const char *user_label_prefix;
1004 static const param_info lang_independent_params[] = {
1005 #define DEFPARAM(ENUM, OPTION, HELP, DEFAULT) \
1006 { OPTION, DEFAULT, HELP },
1007 #include "params.def"
1012 /* Table of language-independent -f options.
1013 STRING is the option name. VARIABLE is the address of the variable.
1014 ON_VALUE is the value to store in VARIABLE
1015 if `-fSTRING' is seen as an option.
1016 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
1018 static const lang_independent_options f_options[] =
1020 {"eliminate-dwarf2-dups", &flag_eliminate_dwarf2_dups, 1 },
1021 {"eliminate-unused-debug-symbols", &flag_debug_only_used_symbols, 1 },
1022 {"eliminate-unused-debug-types", &flag_eliminate_unused_debug_types, 1 },
1023 {"float-store", &flag_float_store, 1 },
1024 {"defer-pop", &flag_defer_pop, 1 },
1025 {"omit-frame-pointer", &flag_omit_frame_pointer, 1 },
1026 {"optimize-sibling-calls", &flag_optimize_sibling_calls, 1 },
1027 {"tracer", &flag_tracer, 1 },
1028 {"unit-at-a-time", &flag_unit_at_a_time, 1 },
1029 {"cse-follow-jumps", &flag_cse_follow_jumps, 1 },
1030 {"cse-skip-blocks", &flag_cse_skip_blocks, 1 },
1031 {"expensive-optimizations", &flag_expensive_optimizations, 1 },
1032 {"thread-jumps", &flag_thread_jumps, 1 },
1033 {"strength-reduce", &flag_strength_reduce, 1 },
1034 {"unroll-loops", &flag_unroll_loops, 1 },
1035 {"unroll-all-loops", &flag_unroll_all_loops, 1 },
1036 {"old-unroll-loops", &flag_old_unroll_loops, 1 },
1037 {"old-unroll-all-loops", &flag_old_unroll_all_loops, 1 },
1038 {"peel-loops", &flag_peel_loops, 1 },
1039 {"unswitch-loops", &flag_unswitch_loops, 1 },
1040 {"prefetch-loop-arrays", &flag_prefetch_loop_arrays, 1 },
1041 {"move-all-movables", &flag_move_all_movables, 1 },
1042 {"reduce-all-givs", &flag_reduce_all_givs, 1 },
1043 {"writable-strings", &flag_writable_strings, 1 },
1044 {"peephole", &flag_no_peephole, 0 },
1045 {"force-mem", &flag_force_mem, 1 },
1046 {"force-addr", &flag_force_addr, 1 },
1047 {"function-cse", &flag_no_function_cse, 0 },
1048 {"inline-functions", &flag_inline_functions, 1 },
1049 {"keep-inline-functions", &flag_keep_inline_functions, 1 },
1050 {"inline", &flag_no_inline, 0 },
1051 {"keep-static-consts", &flag_keep_static_consts, 1 },
1052 {"syntax-only", &flag_syntax_only, 1 },
1053 {"shared-data", &flag_shared_data, 1 },
1054 {"caller-saves", &flag_caller_saves, 1 },
1055 {"pcc-struct-return", &flag_pcc_struct_return, 1 },
1056 {"reg-struct-return", &flag_pcc_struct_return, 0 },
1057 {"delayed-branch", &flag_delayed_branch, 1 },
1058 {"web", &flag_web, 1},
1059 {"gcse", &flag_gcse, 1 },
1060 {"gcse-lm", &flag_gcse_lm, 1 },
1061 {"gcse-sm", &flag_gcse_sm, 1 },
1062 {"gcse-las", &flag_gcse_las, 1 },
1063 {"branch-target-load-optimize", &flag_branch_target_load_optimize, 1 },
1064 {"branch-target-load-optimize2", &flag_branch_target_load_optimize2, 1 },
1065 {"loop-optimize", &flag_loop_optimize, 1 },
1066 {"crossjumping", &flag_crossjumping, 1 },
1067 {"if-conversion", &flag_if_conversion, 1 },
1068 {"if-conversion2", &flag_if_conversion2, 1 },
1069 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1 },
1070 {"rerun-loop-opt", &flag_rerun_loop_opt, 1 },
1071 {"delete-null-pointer-checks", &flag_delete_null_pointer_checks, 1 },
1072 {"schedule-insns", &flag_schedule_insns, 1 },
1073 {"schedule-insns2", &flag_schedule_insns_after_reload, 1 },
1074 {"sched-interblock",&flag_schedule_interblock, 1 },
1075 {"sched-spec",&flag_schedule_speculative, 1 },
1076 {"sched-spec-load",&flag_schedule_speculative_load, 1 },
1077 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1 },
1078 {"sched-stalled-insns", &flag_sched_stalled_insns, 0 },
1079 {"sched-stalled-insns-dep", &flag_sched_stalled_insns_dep, 1 },
1080 {"sched2-use-superblocks", &flag_sched2_use_superblocks, 1 },
1081 {"sched2-use-traces", &flag_sched2_use_traces, 1 },
1082 {"branch-count-reg",&flag_branch_on_count_reg, 1 },
1083 {"pic", &flag_pic, 1 },
1084 {"PIC", &flag_pic, 2 },
1085 {"pie", &flag_pie, 1 },
1086 {"PIE", &flag_pie, 2 },
1087 {"exceptions", &flag_exceptions, 1 },
1088 {"unwind-tables", &flag_unwind_tables, 1 },
1089 {"asynchronous-unwind-tables", &flag_asynchronous_unwind_tables, 1 },
1090 {"non-call-exceptions", &flag_non_call_exceptions, 1 },
1091 {"profile-arcs", &profile_arc_flag, 1 },
1092 {"profile-values", &flag_profile_values, 1 },
1093 {"vpt", &flag_value_profile_transformations, 1 },
1094 {"test-coverage", &flag_test_coverage, 1 },
1095 {"branch-probabilities", &flag_branch_probabilities, 1 },
1096 {"profile", &profile_flag, 1 },
1097 {"reorder-blocks", &flag_reorder_blocks, 1 },
1098 {"reorder-functions", &flag_reorder_functions, 1 },
1099 {"rename-registers", &flag_rename_registers, 1 },
1100 {"cprop-registers", &flag_cprop_registers, 1 },
1101 {"common", &flag_no_common, 0 },
1102 {"inhibit-size-directive", &flag_inhibit_size_directive, 1 },
1103 {"function-sections", &flag_function_sections, 1 },
1104 {"data-sections", &flag_data_sections, 1 },
1105 {"verbose-asm", &flag_verbose_asm, 1 },
1106 {"regmove", &flag_regmove, 1 },
1107 {"optimize-register-move", &flag_regmove, 1 },
1108 {"pack-struct", &flag_pack_struct, 1 },
1109 {"stack-check", &flag_stack_check, 1 },
1110 {"argument-alias", &flag_argument_noalias, 0 },
1111 {"argument-noalias", &flag_argument_noalias, 1 },
1112 {"argument-noalias-global", &flag_argument_noalias, 2 },
1113 {"strict-aliasing", &flag_strict_aliasing, 1 },
1114 {"align-loops", &align_loops, 0 },
1115 {"align-jumps", &align_jumps, 0 },
1116 {"align-labels", &align_labels, 0 },
1117 {"align-functions", &align_functions, 0 },
1118 {"merge-constants", &flag_merge_constants, 1 },
1119 {"merge-all-constants", &flag_merge_constants, 2 },
1120 {"dump-unnumbered", &flag_dump_unnumbered, 1 },
1121 {"instrument-functions", &flag_instrument_function_entry_exit, 1 },
1122 {"zero-initialized-in-bss", &flag_zero_initialized_in_bss, 1 },
1123 {"leading-underscore", &flag_leading_underscore, 1 },
1124 {"ident", &flag_no_ident, 0 },
1125 { "peephole2", &flag_peephole2, 1 },
1126 {"finite-math-only", &flag_finite_math_only, 1 },
1127 { "guess-branch-probability", &flag_guess_branch_prob, 1 },
1128 {"math-errno", &flag_errno_math, 1 },
1129 {"trapping-math", &flag_trapping_math, 1 },
1130 {"rounding-math", &flag_rounding_math, 1 },
1131 {"unsafe-math-optimizations", &flag_unsafe_math_optimizations, 1 },
1132 {"signaling-nans", &flag_signaling_nans, 1 },
1133 {"bounds-check", &flag_bounds_check, 1 },
1134 {"single-precision-constant", &flag_single_precision_constant, 1 },
1135 {"time-report", &time_report, 1 },
1136 {"mem-report", &mem_report, 1 },
1137 { "trapv", &flag_trapv, 1 },
1138 { "wrapv", &flag_wrapv, 1 },
1139 { "new-ra", &flag_new_regalloc, 1 }
1142 /* Here is a table, controlled by the tm.h file, listing each -m switch
1143 and which bits in `target_switches' it should set or clear.
1144 If VALUE is positive, it is bits to set.
1145 If VALUE is negative, -VALUE is bits to clear.
1146 (The sign bit is not used so there is no confusion.) */
1150 const char *const name;
1152 const char *const description;
1154 target_switches[] = TARGET_SWITCHES;
1156 /* This table is similar, but allows the switch to have a value. */
1158 #ifdef TARGET_OPTIONS
1161 const char *const prefix;
1162 const char **const variable;
1163 const char *const description;
1164 const char *const value;
1166 target_options[] = TARGET_OPTIONS;
1169 /* Nonzero means warn about function definitions that default the return type
1170 or that use a null return and have a return-type other than void. */
1172 int warn_return_type;
1174 /* Output files for assembler code (real compiler output)
1175 and debugging dumps. */
1178 FILE *aux_info_file;
1179 FILE *rtl_dump_file = NULL;
1180 FILE *cgraph_dump_file = NULL;
1182 /* The current working directory of a translation. It's generally the
1183 directory from which compilation was initiated, but a preprocessed
1184 file may specify the original directory in which it was
1187 static const char *src_pwd;
1189 /* Initialize src_pwd with the given string, and return true. If it
1190 was already initialized, return false. As a special case, it may
1191 be called with a NULL argument to test whether src_pwd has NOT been
1195 set_src_pwd (const char *pwd)
1200 src_pwd = xstrdup (pwd);
1204 /* Return the directory from which the translation unit was initiated,
1205 in case set_src_pwd() was not called before to assign it a
1212 src_pwd = getpwd ();
1217 /* Called when the start of a function definition is parsed,
1218 this function prints on stderr the name of the function. */
1220 announce_function (tree decl)
1224 if (rtl_dump_and_exit)
1225 verbatim ("%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
1227 verbatim (" %s", (*lang_hooks.decl_printable_name) (decl, 2));
1229 pp_needs_newline (global_dc->printer) = true;
1230 diagnostic_set_last_function (global_dc);
1234 /* Set up a default flag_random_seed and local_tick, unless the user
1235 already specified one. */
1240 if (!flag_random_seed)
1242 unsigned HOST_WIDE_INT value;
1243 static char random_seed[HOST_BITS_PER_WIDE_INT / 4 + 3];
1245 /* Get some more or less random data. */
1246 #ifdef HAVE_GETTIMEOFDAY
1250 gettimeofday (&tv, NULL);
1251 local_tick = tv.tv_sec * 1000 + tv.tv_usec / 1000;
1255 time_t now = time (NULL);
1257 if (now != (time_t)-1)
1258 local_tick = (unsigned) now;
1261 value = local_tick ^ getpid ();
1263 sprintf (random_seed, HOST_WIDE_INT_PRINT_HEX, value);
1264 flag_random_seed = random_seed;
1266 else if (!local_tick)
1271 /* Decode the string P as an integral parameter.
1272 If the string is indeed an integer return its numeric value else
1273 issue an Invalid Option error for the option PNAME and return DEFVAL.
1274 If PNAME is zero just return DEFVAL, do not call error. */
1277 read_integral_parameter (const char *p, const char *pname, const int defval)
1279 const char *endp = p;
1283 if (ISDIGIT (*endp))
1292 error ("invalid option argument `%s'", pname);
1299 /* Return the logarithm of X, base 2, considering X unsigned,
1300 if X is a power of 2. Otherwise, returns -1.
1302 This should be used via the `exact_log2' macro. */
1305 exact_log2_wide (unsigned HOST_WIDE_INT x)
1308 /* Test for 0 or a power of 2. */
1309 if (x == 0 || x != (x & -x))
1311 while ((x >>= 1) != 0)
1316 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1317 If X is 0, return -1.
1319 This should be used via the floor_log2 macro. */
1322 floor_log2_wide (unsigned HOST_WIDE_INT x)
1331 /* Handler for fatal signals, such as SIGSEGV. These are transformed
1332 into ICE messages, which is much more user friendly. In case the
1333 error printer crashes, reset the signal to prevent infinite recursion. */
1336 crash_signal (int signo)
1338 signal (signo, SIG_DFL);
1339 internal_error ("%s", strsignal (signo));
1342 /* Arrange to dump core on error. (The regular error message is still
1343 printed first, except in the case of abort().) */
1346 setup_core_dumping (void)
1349 signal (SIGABRT, SIG_DFL);
1351 #if defined(HAVE_SETRLIMIT)
1354 if (getrlimit (RLIMIT_CORE, &rlim) != 0)
1355 fatal_error ("getting core file size maximum limit: %m");
1356 rlim.rlim_cur = rlim.rlim_max;
1357 if (setrlimit (RLIMIT_CORE, &rlim) != 0)
1358 fatal_error ("setting core file size limit to maximum: %m");
1361 diagnostic_abort_on_error (global_dc);
1365 /* Strip off a legitimate source ending from the input string NAME of
1366 length LEN. Rather than having to know the names used by all of
1367 our front ends, we strip off an ending of a period followed by
1368 up to five characters. (Java uses ".class".) */
1371 strip_off_ending (char *name, int len)
1374 for (i = 2; i < 6 && len > i; i++)
1376 if (name[len - i] == '.')
1378 name[len - i] = '\0';
1384 /* Output a quoted string. */
1387 output_quoted_string (FILE *asm_file, const char *string)
1389 #ifdef OUTPUT_QUOTED_STRING
1390 OUTPUT_QUOTED_STRING (asm_file, string);
1394 putc ('\"', asm_file);
1395 while ((c = *string++) != 0)
1399 if (c == '\"' || c == '\\')
1400 putc ('\\', asm_file);
1404 fprintf (asm_file, "\\%03o", (unsigned char) c);
1406 putc ('\"', asm_file);
1410 /* Output a file name in the form wanted by System V. */
1413 output_file_directive (FILE *asm_file, const char *input_name)
1418 if (input_name == NULL)
1419 input_name = "<stdin>";
1421 len = strlen (input_name);
1422 na = input_name + len;
1424 /* NA gets INPUT_NAME sans directory names. */
1425 while (na > input_name)
1427 if (IS_DIR_SEPARATOR (na[-1]))
1432 #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
1433 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na);
1435 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1436 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1438 fprintf (asm_file, "\t.file\t");
1439 output_quoted_string (asm_file, na);
1440 fputc ('\n', asm_file);
1445 /* Routine to open a dump file. Return true if the dump file is enabled. */
1448 open_dump_file (enum dump_file_index index, tree decl)
1451 const char *open_arg;
1454 if (! dump_file[index].enabled)
1457 timevar_push (TV_DUMP);
1458 if (rtl_dump_file != NULL)
1459 fclose (rtl_dump_file);
1461 sprintf (seq, DUMPFILE_FORMAT, index);
1463 if (! dump_file[index].initialized)
1465 /* If we've not initialized the files, do so now. */
1466 if (graph_dump_format != no_graph
1467 && dump_file[index].graph_dump_p)
1469 dump_name = concat (seq, dump_file[index].extension, NULL);
1470 clean_graph_dump_file (dump_base_name, dump_name);
1473 dump_file[index].initialized = 1;
1479 dump_name = concat (dump_base_name, seq,
1480 dump_file[index].extension, NULL);
1482 rtl_dump_file = fopen (dump_name, open_arg);
1483 if (rtl_dump_file == NULL)
1484 fatal_error ("can't open %s: %m", dump_name);
1489 fprintf (rtl_dump_file, "\n;; Function %s%s\n\n",
1490 (*lang_hooks.decl_printable_name) (decl, 2),
1491 cfun->function_frequency == FUNCTION_FREQUENCY_HOT
1493 : cfun->function_frequency == FUNCTION_FREQUENCY_UNLIKELY_EXECUTED
1494 ? " (unlikely executed)"
1497 timevar_pop (TV_DUMP);
1501 /* Routine to close a dump file. */
1504 close_dump_file (enum dump_file_index index,
1505 void (*func) (FILE *, rtx),
1508 if (! rtl_dump_file)
1511 timevar_push (TV_DUMP);
1513 && graph_dump_format != no_graph
1514 && dump_file[index].graph_dump_p)
1519 sprintf (seq, DUMPFILE_FORMAT, index);
1520 suffix = concat (seq, dump_file[index].extension, NULL);
1521 print_rtl_graph_with_bb (dump_base_name, suffix, insns);
1526 func (rtl_dump_file, insns);
1528 fflush (rtl_dump_file);
1529 fclose (rtl_dump_file);
1531 rtl_dump_file = NULL;
1532 timevar_pop (TV_DUMP);
1535 /* Do any final processing required for the declarations in VEC, of
1536 which there are LEN. We write out inline functions and variables
1537 that have been deferred until this point, but which are required.
1538 Returns nonzero if anything was put out. */
1541 wrapup_global_declarations (tree *vec, int len)
1546 int output_something = 0;
1548 for (i = 0; i < len; i++)
1552 /* We're not deferring this any longer. Assignment is
1553 conditional to avoid needlessly dirtying PCH pages. */
1554 if (DECL_DEFER_OUTPUT (decl) != 0)
1555 DECL_DEFER_OUTPUT (decl) = 0;
1557 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0)
1558 (*lang_hooks.finish_incomplete_decl) (decl);
1561 /* Now emit any global variables or functions that we have been
1562 putting off. We need to loop in case one of the things emitted
1563 here references another one which comes earlier in the list. */
1567 for (i = 0; i < len; i++)
1571 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
1574 /* Don't write out static consts, unless we still need them.
1576 We also keep static consts if not optimizing (for debugging),
1577 unless the user specified -fno-keep-static-consts.
1578 ??? They might be better written into the debug information.
1579 This is possible when using DWARF.
1581 A language processor that wants static constants to be always
1582 written out (even if it is not used) is responsible for
1583 calling rest_of_decl_compilation itself. E.g. the C front-end
1584 calls rest_of_decl_compilation from finish_decl.
1585 One motivation for this is that is conventional in some
1586 environments to write things like:
1587 static const char rcsid[] = "... version string ...";
1588 intending to force the string to be in the executable.
1590 A language processor that would prefer to have unneeded
1591 static constants "optimized away" would just defer writing
1592 them out until here. E.g. C++ does this, because static
1593 constants are often defined in header files.
1595 ??? A tempting alternative (for both C and C++) would be
1596 to force a constant to be written if and only if it is
1597 defined in a main file, as opposed to an include file. */
1599 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl))
1603 if (flag_unit_at_a_time
1604 && cgraph_varpool_node (decl)->finalized)
1606 else if ((flag_unit_at_a_time && !cgraph_global_info_ready)
1607 && (TREE_USED (decl)
1608 || TREE_USED (DECL_ASSEMBLER_NAME (decl))))
1610 else if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
1612 else if (DECL_COMDAT (decl))
1614 else if (TREE_READONLY (decl) && !TREE_PUBLIC (decl)
1615 && (optimize || !flag_keep_static_consts
1616 || DECL_ARTIFICIAL (decl)))
1622 rest_of_decl_compilation (decl, NULL, 1, 1);
1626 if (TREE_CODE (decl) == FUNCTION_DECL
1627 && DECL_INITIAL (decl) != 0
1628 && DECL_SAVED_INSNS (decl) != 0
1629 && DECL_SAVED_INSNS (decl)->saved_for_inline
1630 && (flag_keep_inline_functions
1631 || (TREE_PUBLIC (decl) && !DECL_COMDAT (decl))
1632 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
1635 output_inline_function (decl);
1640 output_something = 1;
1644 return output_something;
1647 /* Issue appropriate warnings for the global declarations in VEC (of
1648 which there are LEN). Output debugging information for them. */
1651 check_global_declarations (tree *vec, int len)
1656 for (i = 0; i < len; i++)
1660 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
1661 && ! TREE_ASM_WRITTEN (decl))
1662 /* Cancel the RTL for this decl so that, if debugging info
1663 output for global variables is still to come,
1664 this one will be omitted. */
1665 SET_DECL_RTL (decl, NULL_RTX);
1667 /* Warn about any function
1668 declared static but not defined.
1669 We don't warn about variables,
1670 because many programs have static variables
1671 that exist only to get some text into the object file. */
1672 if (TREE_CODE (decl) == FUNCTION_DECL
1673 && (warn_unused_function
1674 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
1675 && DECL_INITIAL (decl) == 0
1676 && DECL_EXTERNAL (decl)
1677 && ! DECL_ARTIFICIAL (decl)
1678 && ! TREE_PUBLIC (decl))
1680 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
1681 pedwarn ("%J'%F' used but never defined", decl, decl);
1683 warning ("%J'%F' declared `static' but never defined", decl, decl);
1684 /* This symbol is effectively an "extern" declaration now. */
1685 TREE_PUBLIC (decl) = 1;
1686 assemble_external (decl);
1689 /* Warn about static fns or vars defined but not used. */
1690 if (((warn_unused_function && TREE_CODE (decl) == FUNCTION_DECL)
1691 /* We don't warn about "static const" variables because the
1692 "rcs_id" idiom uses that construction. */
1693 || (warn_unused_variable
1694 && TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
1695 && ! DECL_IN_SYSTEM_HEADER (decl)
1696 && ! TREE_USED (decl)
1697 /* The TREE_USED bit for file-scope decls is kept in the identifier,
1698 to handle multiple external decls in different scopes. */
1699 && ! TREE_USED (DECL_NAME (decl))
1700 && ! DECL_EXTERNAL (decl)
1701 && ! TREE_PUBLIC (decl)
1702 /* A volatile variable might be used in some non-obvious way. */
1703 && ! TREE_THIS_VOLATILE (decl)
1704 /* Global register variables must be declared to reserve them. */
1705 && ! (TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl))
1706 /* Otherwise, ask the language. */
1707 && (*lang_hooks.decls.warn_unused_global) (decl))
1708 warning ("%J'%D' defined but not used", decl, decl);
1710 /* Avoid confusing the debug information machinery when there are
1712 if (errorcount == 0 && sorrycount == 0)
1714 timevar_push (TV_SYMOUT);
1715 (*debug_hooks->global_decl) (decl);
1716 timevar_pop (TV_SYMOUT);
1721 /* Warn about a use of an identifier which was marked deprecated. */
1723 warn_deprecated_use (tree node)
1725 if (node == 0 || !warn_deprecated_decl)
1729 warning ("`%s' is deprecated (declared at %s:%d)",
1730 IDENTIFIER_POINTER (DECL_NAME (node)),
1731 DECL_SOURCE_FILE (node), DECL_SOURCE_LINE (node));
1732 else if (TYPE_P (node))
1734 const char *what = NULL;
1735 tree decl = TYPE_STUB_DECL (node);
1737 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
1738 what = IDENTIFIER_POINTER (TYPE_NAME (node));
1739 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
1740 && DECL_NAME (TYPE_NAME (node)))
1741 what = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node)));
1746 warning ("`%s' is deprecated (declared at %s:%d)", what,
1747 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1749 warning ("`%s' is deprecated", what);
1752 warning ("type is deprecated (declared at %s:%d)",
1753 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1755 warning ("type is deprecated");
1759 /* Save the current INPUT_LOCATION on the top entry in the
1760 INPUT_FILE_STACK. Push a new entry for FILE and LINE, and set the
1761 INPUT_LOCATION accordingly. */
1764 push_srcloc (const char *file, int line)
1766 struct file_stack *fs;
1768 fs = xmalloc (sizeof (struct file_stack));
1769 fs->location = input_location;
1770 fs->next = input_file_stack;
1771 input_filename = file;
1773 input_file_stack = fs;
1774 input_file_stack_tick++;
1777 /* Pop the top entry off the stack of presently open source files.
1778 Restore the INPUT_LOCATION from the new topmost entry on the
1784 struct file_stack *fs;
1786 fs = input_file_stack;
1787 input_location = fs->location;
1788 input_file_stack = fs->next;
1790 input_file_stack_tick++;
1793 /* Compile an entire translation unit. Write a file of assembly
1794 output and various debugging dumps. */
1799 /* Initialize yet another pass. */
1801 init_final (main_input_filename);
1802 coverage_init (aux_base_name);
1804 timevar_push (TV_PARSE);
1806 /* Call the parser, which parses the entire file (calling
1807 rest_of_compilation for each function). */
1808 (*lang_hooks.parse_file) (set_yydebug);
1810 /* In case there were missing block closers,
1811 get us back to the global binding level. */
1812 (*lang_hooks.clear_binding_stack) ();
1814 /* Compilation is now finished except for writing
1815 what's left of the symbol table output. */
1816 timevar_pop (TV_PARSE);
1818 if (flag_syntax_only)
1821 (*lang_hooks.decls.final_write_globals)();
1823 cgraph_varpool_assemble_pending_decls ();
1825 /* This must occur after the loop to output deferred functions.
1826 Else the coverage initializer would not be emitted if all the
1827 functions in this compilation unit were deferred. */
1830 /* Write out any pending weak symbol declarations. */
1834 /* Do dbx symbols. */
1835 timevar_push (TV_SYMOUT);
1837 #ifdef DWARF2_UNWIND_INFO
1838 if (dwarf2out_do_frame ())
1839 dwarf2out_frame_finish ();
1842 (*debug_hooks->finish) (main_input_filename);
1843 timevar_pop (TV_SYMOUT);
1845 /* Output some stuff at end of file if nec. */
1847 dw2_output_indirect_constants ();
1849 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
1851 timevar_push (TV_DUMP);
1852 open_dump_file (DFI_bp, NULL);
1856 close_dump_file (DFI_bp, NULL, NULL_RTX);
1857 timevar_pop (TV_DUMP);
1860 targetm.asm_out.file_end ();
1862 /* Attach a special .ident directive to the end of the file to identify
1863 the version of GCC which compiled this code. The format of the .ident
1864 string is patterned after the ones produced by native SVR4 compilers. */
1867 fprintf (asm_out_file, "%s\"GCC: (GNU) %s\"\n",
1868 IDENT_ASM_OP, version_string);
1871 if (optimize > 0 && open_dump_file (DFI_combine, NULL))
1873 timevar_push (TV_DUMP);
1874 dump_combine_total_stats (rtl_dump_file);
1875 close_dump_file (DFI_combine, NULL, NULL_RTX);
1876 timevar_pop (TV_DUMP);
1880 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
1881 and TYPE_DECL nodes.
1883 This does nothing for local (non-static) variables, unless the
1884 variable is a register variable with an ASMSPEC. In that case, or
1885 if the variable is not an automatic, it sets up the RTL and
1886 outputs any assembler code (label definition, storage allocation
1887 and initialization).
1889 DECL is the declaration. If ASMSPEC is nonzero, it specifies
1890 the assembler symbol name to be used. TOP_LEVEL is nonzero
1891 if this declaration is not within a function. */
1894 rest_of_decl_compilation (tree decl,
1895 const char *asmspec,
1899 /* We deferred calling assemble_alias so that we could collect
1900 other attributes such as visibility. Emit the alias now. */
1903 alias = lookup_attribute ("alias", DECL_ATTRIBUTES (decl));
1906 alias = TREE_VALUE (TREE_VALUE (alias));
1907 alias = get_identifier (TREE_STRING_POINTER (alias));
1908 assemble_alias (decl, alias);
1912 /* Forward declarations for nested functions are not "external",
1913 but we need to treat them as if they were. */
1914 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
1915 || TREE_CODE (decl) == FUNCTION_DECL)
1917 timevar_push (TV_VARCONST);
1920 make_decl_rtl (decl, asmspec);
1922 /* Don't output anything when a tentative file-scope definition
1923 is seen. But at end of compilation, do output code for them. */
1924 if ((at_end || !DECL_DEFER_OUTPUT (decl)) && !DECL_EXTERNAL (decl))
1926 if (flag_unit_at_a_time && !cgraph_global_info_ready
1927 && TREE_CODE (decl) != FUNCTION_DECL && top_level)
1928 cgraph_varpool_finalize_decl (decl);
1930 assemble_variable (decl, top_level, at_end, 0);
1933 #ifdef ASM_FINISH_DECLARE_OBJECT
1934 if (decl == last_assemble_variable_decl)
1936 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
1941 timevar_pop (TV_VARCONST);
1943 else if (DECL_REGISTER (decl) && asmspec != 0)
1945 if (decode_reg_name (asmspec) >= 0)
1947 SET_DECL_RTL (decl, NULL_RTX);
1948 make_decl_rtl (decl, asmspec);
1952 error ("invalid register name `%s' for register variable", asmspec);
1953 DECL_REGISTER (decl) = 0;
1958 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
1959 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
1960 && TREE_CODE (decl) == TYPE_DECL)
1962 timevar_push (TV_SYMOUT);
1963 dbxout_symbol (decl, 0);
1964 timevar_pop (TV_SYMOUT);
1967 #ifdef SDB_DEBUGGING_INFO
1968 else if (write_symbols == SDB_DEBUG && top_level
1969 && TREE_CODE (decl) == TYPE_DECL)
1971 timevar_push (TV_SYMOUT);
1972 sdbout_symbol (decl, 0);
1973 timevar_pop (TV_SYMOUT);
1976 #ifdef DWARF2_DEBUGGING_INFO
1977 else if ((write_symbols == DWARF2_DEBUG
1978 || write_symbols == VMS_AND_DWARF2_DEBUG)
1980 && TREE_CODE (decl) == TYPE_DECL)
1982 timevar_push (TV_SYMOUT);
1983 dwarf2out_decl (decl);
1984 timevar_pop (TV_SYMOUT);
1989 /* Called after finishing a record, union or enumeral type. */
1992 rest_of_type_compilation (
1993 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) \
1994 || defined (SDB_DEBUGGING_INFO) || defined (DWARF2_DEBUGGING_INFO)
1998 tree type ATTRIBUTE_UNUSED,
1999 int toplev ATTRIBUTE_UNUSED
2003 /* Avoid confusing the debug information machinery when there are
2005 if (errorcount != 0 || sorrycount != 0)
2008 timevar_push (TV_SYMOUT);
2009 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2010 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2011 dbxout_symbol (TYPE_STUB_DECL (type), !toplev);
2013 #ifdef SDB_DEBUGGING_INFO
2014 if (write_symbols == SDB_DEBUG)
2015 sdbout_symbol (TYPE_STUB_DECL (type), !toplev);
2017 #ifdef DWARF2_DEBUGGING_INFO
2018 if ((write_symbols == DWARF2_DEBUG
2019 || write_symbols == VMS_AND_DWARF2_DEBUG)
2021 dwarf2out_decl (TYPE_STUB_DECL (type));
2023 timevar_pop (TV_SYMOUT);
2026 /* Turn the RTL into assembly. */
2028 rest_of_handle_final (tree decl, rtx insns)
2030 timevar_push (TV_FINAL);
2035 /* Get the function's name, as described by its RTL. This may be
2036 different from the DECL_NAME name used in the source file. */
2038 x = DECL_RTL (decl);
2039 if (GET_CODE (x) != MEM)
2042 if (GET_CODE (x) != SYMBOL_REF)
2044 fnname = XSTR (x, 0);
2046 assemble_start_function (decl, fnname);
2047 final_start_function (insns, asm_out_file, optimize);
2048 final (insns, asm_out_file, optimize, 0);
2049 final_end_function ();
2051 #ifdef IA64_UNWIND_INFO
2052 /* ??? The IA-64 ".handlerdata" directive must be issued before
2053 the ".endp" directive that closes the procedure descriptor. */
2054 output_function_exception_table ();
2057 assemble_end_function (decl, fnname);
2059 #ifndef IA64_UNWIND_INFO
2060 /* Otherwise, it feels unclean to switch sections in the middle. */
2061 output_function_exception_table ();
2065 fflush (asm_out_file);
2067 /* Release all memory allocated by flow. */
2068 free_basic_block_vars (0);
2070 /* Release all memory held by regsets now. */
2071 regset_release_memory ();
2073 timevar_pop (TV_FINAL);
2079 /* Run delay slot optimization. */
2081 rest_of_handle_delay_slots (tree decl, rtx insns)
2083 timevar_push (TV_DBR_SCHED);
2084 open_dump_file (DFI_dbr, decl);
2086 dbr_schedule (insns, rtl_dump_file);
2088 close_dump_file (DFI_dbr, print_rtl, insns);
2089 timevar_pop (TV_DBR_SCHED);
2096 /* Convert register usage from flat register file usage to a stack
2099 rest_of_handle_stack_regs (tree decl, rtx insns)
2101 #if defined (HAVE_ATTR_length)
2102 /* If flow2 creates new instructions which need splitting
2103 and scheduling after reload is not done, they might not be
2104 splitten until final which doesn't allow splitting
2105 if HAVE_ATTR_length. */
2106 #ifdef INSN_SCHEDULING
2107 if (optimize && !flag_schedule_insns_after_reload)
2112 timevar_push (TV_SHORTEN_BRANCH);
2113 split_all_insns (1);
2114 timevar_pop (TV_SHORTEN_BRANCH);
2118 timevar_push (TV_REG_STACK);
2119 open_dump_file (DFI_stack, decl);
2121 if (reg_to_stack (insns, rtl_dump_file) && optimize)
2123 if (cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK
2124 | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0))
2125 && flag_reorder_blocks)
2127 reorder_basic_blocks ();
2128 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK);
2132 close_dump_file (DFI_stack, print_rtl_with_bb, insns);
2133 timevar_pop (TV_REG_STACK);
2140 /* Machine independent reorg pass. */
2142 rest_of_handle_machine_reorg (tree decl, rtx insns)
2144 timevar_push (TV_MACH_DEP);
2145 open_dump_file (DFI_mach, decl);
2147 (*targetm.machine_dependent_reorg) ();
2149 close_dump_file (DFI_mach, print_rtl, insns);
2150 timevar_pop (TV_MACH_DEP);
2156 /* Run new register allocator. Return TRUE if we must exit
2157 rest_of_compilation upon return. */
2159 rest_of_handle_new_regalloc (tree decl, rtx insns)
2163 delete_trivially_dead_insns (insns, max_reg_num ());
2166 timevar_pop (TV_LOCAL_ALLOC);
2167 if (dump_file[DFI_lreg].enabled)
2169 timevar_push (TV_DUMP);
2171 close_dump_file (DFI_lreg, NULL, NULL);
2172 timevar_pop (TV_DUMP);
2175 /* XXX clean up the whole mess to bring live info in shape again. */
2176 timevar_push (TV_GLOBAL_ALLOC);
2177 open_dump_file (DFI_greg, decl);
2179 build_insn_chain (insns);
2180 failure = reload (insns, 0);
2182 timevar_pop (TV_GLOBAL_ALLOC);
2184 if (dump_file[DFI_greg].enabled)
2186 timevar_push (TV_DUMP);
2188 dump_global_regs (rtl_dump_file);
2190 close_dump_file (DFI_greg, print_rtl_with_bb, insns);
2191 timevar_pop (TV_DUMP);
2197 reload_completed = 1;
2202 /* Run old register allocator. Return TRUE if we must exit
2203 rest_of_compilation upon return. */
2205 rest_of_handle_old_regalloc (tree decl, rtx insns)
2210 /* Allocate the reg_renumber array. */
2211 allocate_reg_info (max_regno, FALSE, TRUE);
2213 /* And the reg_equiv_memory_loc array. */
2214 reg_equiv_memory_loc = xcalloc (max_regno, sizeof (rtx));
2216 allocate_initial_values (reg_equiv_memory_loc);
2218 regclass (insns, max_reg_num (), rtl_dump_file);
2219 rebuild_notes = local_alloc ();
2221 timevar_pop (TV_LOCAL_ALLOC);
2223 /* Local allocation may have turned an indirect jump into a direct
2224 jump. If so, we must rebuild the JUMP_LABEL fields of jumping
2228 timevar_push (TV_JUMP);
2230 rebuild_jump_labels (insns);
2231 purge_all_dead_edges (0);
2233 timevar_pop (TV_JUMP);
2236 if (dump_file[DFI_lreg].enabled)
2238 timevar_push (TV_DUMP);
2240 dump_flow_info (rtl_dump_file);
2241 dump_local_alloc (rtl_dump_file);
2243 close_dump_file (DFI_lreg, print_rtl_with_bb, insns);
2244 timevar_pop (TV_DUMP);
2249 timevar_push (TV_GLOBAL_ALLOC);
2250 open_dump_file (DFI_greg, decl);
2252 /* If optimizing, allocate remaining pseudo-regs. Do the reload
2253 pass fixing up any insns that are invalid. */
2256 failure = global_alloc (rtl_dump_file);
2259 build_insn_chain (insns);
2260 failure = reload (insns, 0);
2263 timevar_pop (TV_GLOBAL_ALLOC);
2265 if (dump_file[DFI_greg].enabled)
2267 timevar_push (TV_DUMP);
2269 dump_global_regs (rtl_dump_file);
2271 close_dump_file (DFI_greg, print_rtl_with_bb, insns);
2272 timevar_pop (TV_DUMP);
2278 /* Run the regrename and cprop passes. */
2280 rest_of_handle_regrename (tree decl, rtx insns)
2282 timevar_push (TV_RENAME_REGISTERS);
2283 open_dump_file (DFI_rnreg, decl);
2285 if (flag_rename_registers)
2286 regrename_optimize ();
2287 if (flag_cprop_registers)
2288 copyprop_hardreg_forward ();
2290 close_dump_file (DFI_rnreg, print_rtl_with_bb, insns);
2291 timevar_pop (TV_RENAME_REGISTERS);
2294 /* Reorder basic blocks. */
2296 rest_of_handle_reorder_blocks (tree decl, rtx insns)
2298 timevar_push (TV_REORDER_BLOCKS);
2299 open_dump_file (DFI_bbro, decl);
2301 /* Last attempt to optimize CFG, as scheduling, peepholing and insn
2302 splitting possibly introduced more crossjumping opportunities. */
2303 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE
2304 | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0));
2306 if (flag_sched2_use_traces && flag_schedule_insns_after_reload)
2308 if (flag_reorder_blocks)
2309 reorder_basic_blocks ();
2310 if (flag_reorder_blocks
2311 || (flag_sched2_use_traces && flag_schedule_insns_after_reload))
2312 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
2314 close_dump_file (DFI_bbro, print_rtl_with_bb, insns);
2315 timevar_pop (TV_REORDER_BLOCKS);
2318 #ifdef INSN_SCHEDULING
2319 /* Run instruction scheduler. */
2321 rest_of_handle_sched (tree decl, rtx insns)
2323 timevar_push (TV_SCHED);
2325 /* Print function header into sched dump now
2326 because doing the sched analysis makes some of the dump. */
2327 if (optimize > 0 && flag_schedule_insns)
2329 open_dump_file (DFI_sched, decl);
2331 /* Do control and data sched analysis,
2332 and write some of the results to dump file. */
2334 schedule_insns (rtl_dump_file);
2336 close_dump_file (DFI_sched, print_rtl_with_bb, insns);
2338 timevar_pop (TV_SCHED);
2343 /* Run second scheduling pass after reload. */
2345 rest_of_handle_sched2 (tree decl, rtx insns)
2347 timevar_push (TV_SCHED2);
2348 open_dump_file (DFI_sched2, decl);
2350 /* Do control and data sched analysis again,
2351 and write some more of the results to dump file. */
2353 split_all_insns (1);
2355 if (flag_sched2_use_superblocks || flag_sched2_use_traces)
2357 schedule_ebbs (rtl_dump_file);
2358 /* No liveness updating code yet, but it should be easy to do.
2359 reg-stack recompute the liveness when needed for now. */
2360 count_or_remove_death_notes (NULL, 1);
2361 cleanup_cfg (CLEANUP_EXPENSIVE);
2364 schedule_insns (rtl_dump_file);
2366 close_dump_file (DFI_sched2, print_rtl_with_bb, insns);
2367 timevar_pop (TV_SCHED2);
2373 /* Register allocation pre-pass, to reduce number of moves necessary
2374 for two-address machines. */
2376 rest_of_handle_regmove (tree decl, rtx insns)
2378 timevar_push (TV_REGMOVE);
2379 open_dump_file (DFI_regmove, decl);
2381 regmove_optimize (insns, max_reg_num (), rtl_dump_file);
2383 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
2384 close_dump_file (DFI_regmove, print_rtl_with_bb, insns);
2385 timevar_pop (TV_REGMOVE);
2392 rest_of_handle_tracer (tree decl, rtx insns)
2394 timevar_push (TV_TRACER);
2395 open_dump_file (DFI_tracer, decl);
2397 dump_flow_info (rtl_dump_file);
2399 cleanup_cfg (CLEANUP_EXPENSIVE);
2400 reg_scan (insns, max_reg_num (), 0);
2401 close_dump_file (DFI_tracer, print_rtl_with_bb, get_insns ());
2402 timevar_pop (TV_TRACER);
2405 /* If-conversion and CFG cleanup. */
2407 rest_of_handle_if_conversion (tree decl, rtx insns)
2409 open_dump_file (DFI_ce1, decl);
2410 if (flag_if_conversion)
2412 timevar_push (TV_IFCVT);
2414 dump_flow_info (rtl_dump_file);
2415 cleanup_cfg (CLEANUP_EXPENSIVE);
2416 reg_scan (insns, max_reg_num (), 0);
2418 timevar_pop (TV_IFCVT);
2420 timevar_push (TV_JUMP);
2421 cleanup_cfg (CLEANUP_EXPENSIVE);
2422 reg_scan (insns, max_reg_num (), 0);
2423 timevar_pop (TV_JUMP);
2424 close_dump_file (DFI_ce1, print_rtl_with_bb, get_insns ());
2427 /* Rerun if-conversion, as combine may have simplified things enough
2428 to now meet sequence length restrictions. */
2430 rest_of_handle_if_after_combine (tree decl, rtx insns)
2432 timevar_push (TV_IFCVT);
2433 open_dump_file (DFI_ce2, decl);
2439 close_dump_file (DFI_ce2, print_rtl_with_bb, insns);
2440 timevar_pop (TV_IFCVT);
2444 rest_of_handle_web (tree decl, rtx insns)
2446 open_dump_file (DFI_web, decl);
2447 timevar_push (TV_WEB);
2449 delete_trivially_dead_insns (insns, max_reg_num ());
2450 cleanup_cfg (CLEANUP_EXPENSIVE);
2452 timevar_pop (TV_WEB);
2453 close_dump_file (DFI_web, print_rtl_with_bb, insns);
2454 reg_scan (get_insns (), max_reg_num (), 0);
2457 /* Do branch profiling and static profile estimation passes. */
2459 rest_of_handle_branch_prob (tree decl, rtx insns)
2463 timevar_push (TV_BRANCH_PROB);
2464 open_dump_file (DFI_bp, decl);
2466 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
2469 /* Discover and record the loop depth at the head of each basic
2470 block. The loop infrastructure does the real job for us. */
2471 flow_loops_find (&loops, LOOP_TREE);
2474 flow_loops_dump (&loops, rtl_dump_file, NULL, 0);
2476 /* Estimate using heuristics if no profiling info is available. */
2477 if (flag_guess_branch_prob)
2478 estimate_probability (&loops);
2480 flow_loops_free (&loops);
2481 close_dump_file (DFI_bp, print_rtl_with_bb, insns);
2482 timevar_pop (TV_BRANCH_PROB);
2485 /* Do optimizations based on expression value profiles. */
2487 rest_of_handle_value_profile_transformations (tree decl, rtx insns)
2489 open_dump_file (DFI_vpt, decl);
2490 timevar_push (TV_VPT);
2492 if (value_profile_transformations ())
2493 cleanup_cfg (CLEANUP_EXPENSIVE);
2495 timevar_pop (TV_VPT);
2496 close_dump_file (DFI_vpt, print_rtl_with_bb, insns);
2499 /* Do control and data flow analysis; write some of the results to the
2502 rest_of_handle_cfg (tree decl, rtx insns)
2504 open_dump_file (DFI_cfg, decl);
2506 dump_flow_info (rtl_dump_file);
2508 cleanup_cfg (CLEANUP_EXPENSIVE
2509 | (flag_thread_jumps ? CLEANUP_THREADING : 0));
2511 /* It may make more sense to mark constant functions after dead code is
2512 eliminated by life_analysis, but we need to do it early, as -fprofile-arcs
2513 may insert code making function non-constant, but we still must consider
2514 it as constant, otherwise -fbranch-probabilities will not read data back.
2516 life_analysis rarely eliminates modification of external memory.
2519 mark_constant_function ();
2521 close_dump_file (DFI_cfg, print_rtl_with_bb, insns);
2524 /* Purge addressofs. */
2526 rest_of_handle_addressof (tree decl, rtx insns)
2528 open_dump_file (DFI_addressof, decl);
2530 purge_addressof (insns);
2531 if (optimize && purge_all_dead_edges (0))
2532 delete_unreachable_blocks ();
2533 reg_scan (insns, max_reg_num (), 1);
2535 close_dump_file (DFI_addressof, print_rtl, insns);
2538 /* We may have potential sibling or tail recursion sites. Select one
2539 (of possibly multiple) methods of performing the call. */
2541 rest_of_handle_sibling_calls (rtx insns)
2544 optimize_sibling_and_tail_recursive_calls ();
2546 /* Recompute the CFG as sibling optimization clobbers it randomly. */
2547 free_bb_for_insn ();
2548 find_exception_handler_labels ();
2549 rebuild_jump_labels (insns);
2550 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2552 /* There is pass ordering problem - we must lower NOTE_INSN_PREDICTION
2553 notes before simplifying cfg and we must do lowering after sibcall
2554 that unhides parts of RTL chain and cleans up the CFG.
2556 Until sibcall is replaced by tree-level optimizer, lets just
2557 sweep away the NOTE_INSN_PREDICTION notes that leaked out. */
2558 for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
2559 if (GET_CODE (insn) == NOTE
2560 && NOTE_LINE_NUMBER (insn) == NOTE_INSN_PREDICTION)
2563 close_dump_file (DFI_sibling, print_rtl, get_insns ());
2566 /* Perform jump bypassing and control flow optimizations. */
2568 rest_of_handle_jump_bypass (tree decl, rtx insns)
2570 timevar_push (TV_BYPASS);
2571 open_dump_file (DFI_bypass, decl);
2573 cleanup_cfg (CLEANUP_EXPENSIVE);
2575 if (bypass_jumps (rtl_dump_file))
2577 rebuild_jump_labels (insns);
2578 cleanup_cfg (CLEANUP_EXPENSIVE);
2579 delete_trivially_dead_insns (insns, max_reg_num ());
2582 close_dump_file (DFI_bypass, print_rtl_with_bb, insns);
2583 timevar_pop (TV_BYPASS);
2587 #ifdef ENABLE_CHECKING
2588 verify_flow_info ();
2592 /* Handle inlining of functions in rest_of_compilation. Return TRUE
2593 if we must exit rest_of_compilation upon return. */
2595 rest_of_handle_inlining (tree decl)
2602 /* If we are reconsidering an inline function at the end of
2603 compilation, skip the stuff for making it inline. */
2604 if (cfun->rtl_inline_init)
2606 cfun->rtl_inline_init = 1;
2608 /* If this is nested inside an inlined external function, pretend
2609 it was only declared. Since we cannot inline such functions,
2610 generating code for this one is not only not necessary but will
2611 confuse some debugging output writers. */
2612 for (parent = DECL_CONTEXT (current_function_decl);
2613 parent != NULL_TREE;
2614 parent = get_containing_scope (parent))
2615 if (TREE_CODE (parent) == FUNCTION_DECL
2616 && DECL_INLINE (parent) && DECL_EXTERNAL (parent))
2618 DECL_INITIAL (decl) = 0;
2621 else if (TYPE_P (parent))
2622 /* A function in a local class should be treated normally. */
2625 /* If requested, consider whether to make this function inline. */
2626 if ((DECL_INLINE (decl) && !flag_no_inline)
2627 || flag_inline_functions)
2629 timevar_push (TV_INTEGRATION);
2630 lose = function_cannot_inline_p (decl);
2631 timevar_pop (TV_INTEGRATION);
2632 if (lose || ! optimize)
2634 if (warn_inline && lose && DECL_INLINE (decl))
2636 char *msg = concat ("%J", lose, NULL);
2637 warning (msg, decl);
2640 DECL_ABSTRACT_ORIGIN (decl) = 0;
2641 /* Don't really compile an extern inline function.
2642 If we can't make it inline, pretend
2643 it was only declared. */
2644 if (DECL_EXTERNAL (decl))
2646 DECL_INITIAL (decl) = 0;
2651 inlinable = DECL_INLINE (decl) = 1;
2654 insns = get_insns ();
2656 /* Dump the rtl code if we are dumping rtl. */
2658 if (open_dump_file (DFI_rtl, decl))
2660 if (DECL_SAVED_INSNS (decl) && DECL_SAVED_INSNS (decl)->saved_for_inline)
2661 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2662 close_dump_file (DFI_rtl, print_rtl, insns);
2665 /* Convert from NOTE_INSN_EH_REGION style notes, and do other
2666 sorts of eh initialization. Delay this until after the
2667 initial rtl dump so that we can see the original nesting. */
2668 convert_from_eh_region_ranges ();
2670 /* If function is inline, and we don't yet know whether to
2671 compile it by itself, defer decision till end of compilation.
2672 wrapup_global_declarations will (indirectly) call
2673 rest_of_compilation again for those functions that need to
2674 be output. Also defer those functions that we are supposed
2678 || (DECL_INLINE (decl)
2679 && flag_inline_functions
2680 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2681 && ! TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))
2682 && ! flag_keep_inline_functions)
2683 || DECL_EXTERNAL (decl))))
2684 DECL_DEFER_OUTPUT (decl) = 1;
2686 if (DECL_INLINE (decl))
2687 /* DWARF wants separate debugging info for abstract and
2688 concrete instances of all inline functions, including those
2689 declared inline but not inlined, and those inlined even
2690 though they weren't declared inline. Conveniently, that's
2691 what DECL_INLINE means at this point. */
2692 (*debug_hooks->deferred_inline_function) (decl);
2694 if (DECL_DEFER_OUTPUT (decl))
2696 /* If -Wreturn-type, we have to do a bit of compilation. We just
2697 want to call cleanup the cfg to figure out whether or not we can
2698 fall off the end of the function; we do the minimum amount of
2699 work necessary to make that safe. */
2700 if (warn_return_type)
2702 int saved_optimize = optimize;
2705 rebuild_jump_labels (insns);
2706 find_exception_handler_labels ();
2707 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2708 cleanup_cfg (CLEANUP_PRE_SIBCALL | CLEANUP_PRE_LOOP);
2709 optimize = saved_optimize;
2711 /* CFG is no longer maintained up-to-date. */
2712 free_bb_for_insn ();
2715 set_nothrow_function_flags ();
2716 if (current_function_nothrow)
2717 /* Now we know that this can't throw; set the flag for the benefit
2718 of other functions later in this translation unit. */
2719 TREE_NOTHROW (current_function_decl) = 1;
2721 timevar_push (TV_INTEGRATION);
2722 save_for_inline (decl);
2723 timevar_pop (TV_INTEGRATION);
2724 DECL_SAVED_INSNS (decl)->inlinable = inlinable;
2728 /* If specified extern inline but we aren't inlining it, we are
2729 done. This goes for anything that gets here with DECL_EXTERNAL
2730 set, not just things with DECL_INLINE. */
2731 return (bool) DECL_EXTERNAL (decl);
2734 /* Try to identify useless null pointer tests and delete them. */
2736 rest_of_handle_null_pointer (tree decl, rtx insns)
2738 open_dump_file (DFI_null, decl);
2740 dump_flow_info (rtl_dump_file);
2742 if (delete_null_pointer_checks (insns))
2743 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2745 close_dump_file (DFI_null, print_rtl_with_bb, insns);
2748 /* Try combining insns through substitution. */
2750 rest_of_handle_combine (tree decl, rtx insns)
2752 int rebuild_jump_labels_after_combine = 0;
2754 timevar_push (TV_COMBINE);
2755 open_dump_file (DFI_combine, decl);
2757 rebuild_jump_labels_after_combine
2758 = combine_instructions (insns, max_reg_num ());
2760 /* Combining insns may have turned an indirect jump into a
2761 direct jump. Rebuild the JUMP_LABEL fields of jumping
2763 if (rebuild_jump_labels_after_combine)
2765 timevar_push (TV_JUMP);
2766 rebuild_jump_labels (insns);
2767 timevar_pop (TV_JUMP);
2769 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
2772 close_dump_file (DFI_combine, print_rtl_with_bb, insns);
2773 timevar_pop (TV_COMBINE);
2778 /* Perform life analysis. */
2780 rest_of_handle_life (tree decl, rtx insns)
2782 open_dump_file (DFI_life, decl);
2785 #ifdef ENABLE_CHECKING
2786 verify_flow_info ();
2788 life_analysis (insns, rtl_dump_file, PROP_FINAL);
2790 cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0) | CLEANUP_UPDATE_LIFE
2791 | (flag_thread_jumps ? CLEANUP_THREADING : 0));
2792 timevar_pop (TV_FLOW);
2794 if (warn_uninitialized)
2796 uninitialized_vars_warning (DECL_INITIAL (decl));
2798 setjmp_args_warning ();
2803 if (!flag_new_regalloc && initialize_uninitialized_subregs ())
2805 /* Insns were inserted, and possibly pseudos created, so
2806 things might look a bit different. */
2807 insns = get_insns ();
2808 allocate_reg_life_data ();
2809 update_life_info (NULL, UPDATE_LIFE_GLOBAL_RM_NOTES,
2810 PROP_LOG_LINKS | PROP_REG_INFO | PROP_DEATH_NOTES);
2816 close_dump_file (DFI_life, print_rtl_with_bb, insns);
2821 /* Perform common subexpression elimination. Nonzero value from
2822 `cse_main' means that jumps were simplified and some code may now
2823 be unreachable, so do jump optimization again. */
2825 rest_of_handle_cse (tree decl, rtx insns)
2829 open_dump_file (DFI_cse, decl);
2831 dump_flow_info (rtl_dump_file);
2832 timevar_push (TV_CSE);
2834 reg_scan (insns, max_reg_num (), 1);
2836 tem = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
2838 rebuild_jump_labels (insns);
2839 if (purge_all_dead_edges (0))
2840 delete_unreachable_blocks ();
2842 delete_trivially_dead_insns (insns, max_reg_num ());
2844 /* If we are not running more CSE passes, then we are no longer
2845 expecting CSE to be run. But always rerun it in a cheap mode. */
2846 cse_not_expected = !flag_rerun_cse_after_loop && !flag_gcse;
2848 if (tem || optimize > 1)
2849 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2850 /* Try to identify useless null pointer tests and delete them. */
2851 if (flag_delete_null_pointer_checks)
2853 timevar_push (TV_JUMP);
2855 if (delete_null_pointer_checks (insns))
2856 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2857 timevar_pop (TV_JUMP);
2860 /* The second pass of jump optimization is likely to have
2861 removed a bunch more instructions. */
2862 renumber_insns (rtl_dump_file);
2864 timevar_pop (TV_CSE);
2865 close_dump_file (DFI_cse, print_rtl_with_bb, insns);
2868 /* Run second CSE pass after loop optimizations. */
2870 rest_of_handle_cse2 (tree decl, rtx insns)
2874 timevar_push (TV_CSE2);
2875 open_dump_file (DFI_cse2, decl);
2877 dump_flow_info (rtl_dump_file);
2878 /* CFG is no longer maintained up-to-date. */
2879 tem = cse_main (insns, max_reg_num (), 1, rtl_dump_file);
2880 purge_all_dead_edges (0);
2881 delete_trivially_dead_insns (insns, max_reg_num ());
2885 timevar_push (TV_JUMP);
2886 rebuild_jump_labels (insns);
2887 cleanup_cfg (CLEANUP_EXPENSIVE);
2888 timevar_pop (TV_JUMP);
2890 reg_scan (insns, max_reg_num (), 0);
2891 close_dump_file (DFI_cse2, print_rtl_with_bb, insns);
2893 timevar_pop (TV_CSE2);
2896 /* Perform global cse. */
2898 rest_of_handle_gcse (tree decl, rtx insns)
2900 int save_csb, save_cfj;
2903 timevar_push (TV_GCSE);
2904 open_dump_file (DFI_gcse, decl);
2906 tem = gcse_main (insns, rtl_dump_file);
2907 rebuild_jump_labels (insns);
2908 delete_trivially_dead_insns (insns, max_reg_num ());
2910 save_csb = flag_cse_skip_blocks;
2911 save_cfj = flag_cse_follow_jumps;
2912 flag_cse_skip_blocks = flag_cse_follow_jumps = 0;
2914 /* Instantiate any remaining CONSTANT_P_RTX nodes. */
2915 if (current_function_calls_constant_p)
2916 purge_builtin_constant_p ();
2918 /* If -fexpensive-optimizations, re-run CSE to clean up things done
2920 if (flag_expensive_optimizations)
2922 timevar_push (TV_CSE);
2923 reg_scan (insns, max_reg_num (), 1);
2924 tem2 = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
2925 purge_all_dead_edges (0);
2926 delete_trivially_dead_insns (insns, max_reg_num ());
2927 timevar_pop (TV_CSE);
2928 cse_not_expected = !flag_rerun_cse_after_loop;
2931 /* If gcse or cse altered any jumps, rerun jump optimizations to clean
2932 things up. Then possibly re-run CSE again. */
2936 timevar_push (TV_JUMP);
2937 rebuild_jump_labels (insns);
2938 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2939 timevar_pop (TV_JUMP);
2941 if (flag_expensive_optimizations)
2943 timevar_push (TV_CSE);
2944 reg_scan (insns, max_reg_num (), 1);
2945 tem2 = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
2946 purge_all_dead_edges (0);
2947 delete_trivially_dead_insns (insns, max_reg_num ());
2948 timevar_pop (TV_CSE);
2952 close_dump_file (DFI_gcse, print_rtl_with_bb, insns);
2953 timevar_pop (TV_GCSE);
2956 flag_cse_skip_blocks = save_csb;
2957 flag_cse_follow_jumps = save_cfj;
2958 #ifdef ENABLE_CHECKING
2959 verify_flow_info ();
2963 /* Move constant computations out of loops. */
2965 rest_of_handle_loop_optimize (tree decl, rtx insns)
2967 int do_unroll, do_prefetch;
2969 timevar_push (TV_LOOP);
2970 delete_dead_jumptables ();
2971 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2972 open_dump_file (DFI_loop, decl);
2974 /* CFG is no longer maintained up-to-date. */
2975 free_bb_for_insn ();
2977 if (flag_unroll_loops)
2978 do_unroll = 0; /* Having two unrollers is useless. */
2980 do_unroll = flag_old_unroll_loops ? LOOP_UNROLL : LOOP_AUTO_UNROLL;
2981 do_prefetch = flag_prefetch_loop_arrays ? LOOP_PREFETCH : 0;
2983 if (flag_rerun_loop_opt)
2985 cleanup_barriers ();
2987 /* We only want to perform unrolling once. */
2988 loop_optimize (insns, rtl_dump_file, do_unroll);
2991 /* The first call to loop_optimize makes some instructions
2992 trivially dead. We delete those instructions now in the
2993 hope that doing so will make the heuristics in loop work
2994 better and possibly speed up compilation. */
2995 delete_trivially_dead_insns (insns, max_reg_num ());
2997 /* The regscan pass is currently necessary as the alias
2998 analysis code depends on this information. */
2999 reg_scan (insns, max_reg_num (), 1);
3001 cleanup_barriers ();
3002 loop_optimize (insns, rtl_dump_file, do_unroll | LOOP_BCT | do_prefetch);
3004 /* Loop can create trivially dead instructions. */
3005 delete_trivially_dead_insns (insns, max_reg_num ());
3006 close_dump_file (DFI_loop, print_rtl, insns);
3007 timevar_pop (TV_LOOP);
3008 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3013 /* Perform loop optimizations. It might be better to do them a bit
3014 sooner, but we want the profile feedback to work more
3017 rest_of_handle_loop2 (tree decl, rtx insns)
3019 struct loops *loops;
3020 timevar_push (TV_LOOP);
3021 open_dump_file (DFI_loop2, decl);
3023 dump_flow_info (rtl_dump_file);
3025 loops = loop_optimizer_init (rtl_dump_file);
3029 /* The optimizations: */
3030 if (flag_unswitch_loops)
3031 unswitch_loops (loops);
3033 if (flag_peel_loops || flag_unroll_loops)
3034 unroll_and_peel_loops (loops,
3035 (flag_peel_loops ? UAP_PEEL : 0) |
3036 (flag_unroll_loops ? UAP_UNROLL : 0) |
3037 (flag_unroll_all_loops ? UAP_UNROLL_ALL : 0));
3039 loop_optimizer_finalize (loops, rtl_dump_file);
3042 cleanup_cfg (CLEANUP_EXPENSIVE);
3043 delete_trivially_dead_insns (insns, max_reg_num ());
3044 reg_scan (insns, max_reg_num (), 0);
3046 dump_flow_info (rtl_dump_file);
3047 close_dump_file (DFI_loop2, print_rtl_with_bb, get_insns ());
3048 timevar_pop (TV_LOOP);
3052 /* This is called from finish_function (within langhooks.parse_file)
3053 after each top-level definition is parsed.
3054 It is supposed to compile that function or variable
3055 and output the assembler code for it.
3056 After we return, the tree storage is freed. */
3059 rest_of_compilation (tree decl)
3063 timevar_push (TV_REST_OF_COMPILATION);
3065 /* Register rtl specific functions for cfg. */
3066 rtl_register_cfg_hooks ();
3068 /* Now that we're out of the frontend, we shouldn't have any more
3069 CONCATs anywhere. */
3070 generating_concat_p = 0;
3072 /* When processing delayed functions, prepare_function_start() won't
3073 have been run to re-initialize it. */
3074 cse_not_expected = ! optimize;
3076 /* First, make sure that NOTE_BLOCK is set correctly for each
3077 NOTE_INSN_BLOCK_BEG/NOTE_INSN_BLOCK_END note. */
3078 if (!cfun->x_whole_function_mode_p)
3081 /* In function-at-a-time mode, we do not attempt to keep the BLOCK
3082 tree in sensible shape. So, we just recalculate it here. */
3083 if (cfun->x_whole_function_mode_p)
3088 if (rest_of_handle_inlining (decl))
3089 goto exit_rest_of_compilation;
3091 /* If we're emitting a nested function, make sure its parent gets
3092 emitted as well. Doing otherwise confuses debug info. */
3095 for (parent = DECL_CONTEXT (current_function_decl);
3096 parent != NULL_TREE;
3097 parent = get_containing_scope (parent))
3098 if (TREE_CODE (parent) == FUNCTION_DECL)
3099 TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (parent)) = 1;
3102 /* We are now committed to emitting code for this function. Do any
3103 preparation, such as emitting abstract debug info for the inline
3104 before it gets mangled by optimization. */
3105 if (cgraph_function_possibly_inlined_p (decl))
3106 (*debug_hooks->outlining_inline_function) (decl);
3108 /* Remove any notes we don't need. That will make iterating
3109 over the instruction sequence faster, and allow the garbage
3110 collector to reclaim the memory used by the notes. */
3111 remove_unnecessary_notes ();
3116 /* Initialize some variables used by the optimizers. */
3117 init_function_for_compilation ();
3119 if (! DECL_DEFER_OUTPUT (decl))
3120 TREE_ASM_WRITTEN (decl) = 1;
3122 /* Now that integrate will no longer see our rtl, we need not
3123 distinguish between the return value of this function and the
3124 return value of called functions. Also, we can remove all SETs
3125 of subregs of hard registers; they are only here because of
3126 integrate. Also, we can now initialize pseudos intended to
3127 carry magic hard reg data throughout the function. */
3128 rtx_equal_function_value_matters = 0;
3129 purge_hard_subreg_sets (get_insns ());
3131 /* Early return if there were errors. We can run afoul of our
3132 consistency checks, and there's not really much point in fixing them.
3133 Don't return yet if -Wreturn-type; we need to do cleanup_cfg. */
3134 if (((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
3135 || errorcount || sorrycount)
3136 goto exit_rest_of_compilation;
3138 timevar_push (TV_JUMP);
3139 open_dump_file (DFI_sibling, decl);
3140 insns = get_insns ();
3141 rebuild_jump_labels (insns);
3142 find_exception_handler_labels ();
3143 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3145 delete_unreachable_blocks ();
3147 /* We have to issue these warnings now already, because CFG cleanups
3148 further down may destroy the required information. */
3149 check_function_return_warnings ();
3151 /* Turn NOTE_INSN_PREDICTIONs into branch predictions. */
3152 if (flag_guess_branch_prob)
3154 timevar_push (TV_BRANCH_PROB);
3155 note_prediction_to_br_prob ();
3156 timevar_pop (TV_BRANCH_PROB);
3159 if (flag_optimize_sibling_calls)
3160 rest_of_handle_sibling_calls (insns);
3162 timevar_pop (TV_JUMP);
3164 insn_locators_initialize ();
3165 /* Complete generation of exception handling code. */
3168 timevar_push (TV_JUMP);
3169 open_dump_file (DFI_eh, decl);
3171 finish_eh_generation ();
3173 close_dump_file (DFI_eh, print_rtl, get_insns ());
3174 timevar_pop (TV_JUMP);
3177 /* Delay emitting hard_reg_initial_value sets until after EH landing pad
3178 generation, which might create new sets. */
3179 emit_initial_value_sets ();
3182 /* If we are doing position-independent code generation, now
3183 is the time to output special prologues and epilogues.
3184 We do not want to do this earlier, because it just clutters
3185 up inline functions with meaningless insns. */
3190 insns = get_insns ();
3192 /* Copy any shared structure that should not be shared. */
3193 unshare_all_rtl (current_function_decl, insns);
3195 #ifdef SETJMP_VIA_SAVE_AREA
3196 /* This must be performed before virtual register instantiation.
3197 Please be aware the everything in the compiler that can look
3198 at the RTL up to this point must understand that REG_SAVE_AREA
3199 is just like a use of the REG contained inside. */
3200 if (current_function_calls_alloca)
3201 optimize_save_area_alloca (insns);
3204 /* Instantiate all virtual registers. */
3205 instantiate_virtual_regs (current_function_decl, insns);
3207 open_dump_file (DFI_jump, decl);
3209 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
3210 are initialized and to compute whether control can drop off the end
3213 timevar_push (TV_JUMP);
3214 /* Turn NOTE_INSN_EXPECTED_VALUE into REG_BR_PROB. Do this
3215 before jump optimization switches branch directions. */
3216 if (flag_guess_branch_prob)
3217 expected_value_to_br_prob ();
3219 reg_scan (insns, max_reg_num (), 0);
3220 rebuild_jump_labels (insns);
3221 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3222 delete_trivially_dead_insns (insns, max_reg_num ());
3224 dump_flow_info (rtl_dump_file);
3225 cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0) | CLEANUP_PRE_LOOP
3226 | (flag_thread_jumps ? CLEANUP_THREADING : 0));
3230 free_bb_for_insn ();
3231 copy_loop_headers (insns);
3232 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3234 purge_line_number_notes (insns);
3236 timevar_pop (TV_JUMP);
3237 close_dump_file (DFI_jump, print_rtl, insns);
3239 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
3240 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
3241 goto exit_rest_of_compilation;
3243 timevar_push (TV_JUMP);
3246 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
3248 if (flag_delete_null_pointer_checks)
3249 rest_of_handle_null_pointer (decl, insns);
3251 /* Jump optimization, and the removal of NULL pointer checks, may
3252 have reduced the number of instructions substantially. CSE, and
3253 future passes, allocate arrays whose dimensions involve the
3254 maximum instruction UID, so if we can reduce the maximum UID
3255 we'll save big on memory. */
3256 renumber_insns (rtl_dump_file);
3257 timevar_pop (TV_JUMP);
3259 close_dump_file (DFI_jump, print_rtl_with_bb, insns);
3264 rest_of_handle_cse (decl, insns);
3266 rest_of_handle_addressof (decl, insns);
3273 rest_of_handle_gcse (decl, insns);
3275 if (flag_loop_optimize)
3276 rest_of_handle_loop_optimize (decl, insns);
3279 rest_of_handle_jump_bypass (decl, insns);
3282 timevar_push (TV_FLOW);
3284 rest_of_handle_cfg (decl, insns);
3287 || profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
3289 rest_of_handle_branch_prob (decl, insns);
3291 if (flag_branch_probabilities
3292 && flag_profile_values
3293 && flag_value_profile_transformations)
3294 rest_of_handle_value_profile_transformations (decl, insns);
3296 /* Remove the death notes created for vpt. */
3297 if (flag_profile_values)
3298 count_or_remove_death_notes (NULL, 1);
3302 rest_of_handle_if_conversion (decl, insns);
3305 rest_of_handle_tracer (decl, insns);
3308 && (flag_unswitch_loops
3310 || flag_unroll_loops))
3311 rest_of_handle_loop2 (decl, insns);
3314 rest_of_handle_web (decl, insns);
3316 if (flag_rerun_cse_after_loop)
3317 rest_of_handle_cse2 (decl, insns);
3319 cse_not_expected = 1;
3321 rest_of_handle_life (decl, insns);
3324 rest_of_handle_combine (decl, insns);
3326 if (flag_if_conversion)
3327 rest_of_handle_if_after_combine (decl, insns);
3329 if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
3330 rest_of_handle_regmove (decl, insns);
3332 /* Do unconditional splitting before register allocation to allow machine
3333 description to add extra information not needed previously. */
3334 split_all_insns (1);
3336 #ifdef OPTIMIZE_MODE_SWITCHING
3337 timevar_push (TV_MODE_SWITCH);
3340 optimize_mode_switching (NULL);
3343 timevar_pop (TV_MODE_SWITCH);
3346 /* Any of the several passes since flow1 will have munged register
3347 lifetime data a bit. We need it to be up to date for scheduling
3348 (see handling of reg_known_equiv in init_alias_analysis). */
3349 recompute_reg_usage (insns, !optimize_size);
3351 #ifdef INSN_SCHEDULING
3352 rest_of_handle_sched (decl, insns);
3355 /* Determine if the current function is a leaf before running reload
3356 since this can impact optimizations done by the prologue and
3357 epilogue thus changing register elimination offsets. */
3358 current_function_is_leaf = leaf_function_p ();
3360 timevar_push (TV_LOCAL_ALLOC);
3361 open_dump_file (DFI_lreg, decl);
3363 if (flag_new_regalloc)
3365 if (rest_of_handle_new_regalloc (decl, insns))
3366 goto exit_rest_of_compilation;
3370 if (rest_of_handle_old_regalloc (decl, insns))
3371 goto exit_rest_of_compilation;
3376 open_dump_file (DFI_postreload, decl);
3378 /* Do a very simple CSE pass over just the hard registers. */
3381 timevar_push (TV_RELOAD_CSE_REGS);
3382 reload_cse_regs (insns);
3383 timevar_pop (TV_RELOAD_CSE_REGS);
3386 close_dump_file (DFI_postreload, print_rtl_with_bb, insns);
3388 /* Re-create the death notes which were deleted during reload. */
3389 timevar_push (TV_FLOW2);
3390 open_dump_file (DFI_flow2, decl);
3392 #ifdef ENABLE_CHECKING
3393 verify_flow_info ();
3396 /* If optimizing, then go ahead and split insns now. */
3400 split_all_insns (0);
3402 if (flag_branch_target_load_optimize)
3404 open_dump_file (DFI_branch_target_load, decl);
3406 branch_target_load_optimize (insns, false);
3408 close_dump_file (DFI_branch_target_load, print_rtl_with_bb, insns);
3414 cleanup_cfg (CLEANUP_EXPENSIVE);
3416 /* On some machines, the prologue and epilogue code, or parts thereof,
3417 can be represented as RTL. Doing so lets us schedule insns between
3418 it and the rest of the code and also allows delayed branch
3419 scheduling to operate in the epilogue. */
3420 thread_prologue_and_epilogue_insns (insns);
3421 epilogue_completed = 1;
3425 life_analysis (insns, rtl_dump_file, PROP_FINAL);
3426 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE
3427 | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0));
3429 /* This is kind of a heuristic. We need to run combine_stack_adjustments
3430 even for machines with possibly nonzero RETURN_POPS_ARGS
3431 and ACCUMULATE_OUTGOING_ARGS. We expect that only ports having
3432 push instructions will have popping returns. */
3433 #ifndef PUSH_ROUNDING
3434 if (!ACCUMULATE_OUTGOING_ARGS)
3436 combine_stack_adjustments ();
3441 flow2_completed = 1;
3443 close_dump_file (DFI_flow2, print_rtl_with_bb, insns);
3444 timevar_pop (TV_FLOW2);
3446 #ifdef HAVE_peephole2
3447 if (optimize > 0 && flag_peephole2)
3449 timevar_push (TV_PEEPHOLE2);
3450 open_dump_file (DFI_peephole2, decl);
3452 peephole2_optimize (rtl_dump_file);
3454 close_dump_file (DFI_peephole2, print_rtl_with_bb, insns);
3455 timevar_pop (TV_PEEPHOLE2);
3461 if (flag_rename_registers || flag_cprop_registers)
3462 rest_of_handle_regrename (decl, insns);
3464 rest_of_handle_reorder_blocks (decl, insns);
3467 if (flag_if_conversion2)
3469 timevar_push (TV_IFCVT2);
3470 open_dump_file (DFI_ce3, decl);
3474 close_dump_file (DFI_ce3, print_rtl_with_bb, insns);
3475 timevar_pop (TV_IFCVT2);
3478 if (flag_branch_target_load_optimize2)
3480 /* Leave this a warning for now so that it is possible to experiment
3481 with running this pass twice. In 3.6, we should either make this
3482 an error, or use separate dump files. */
3483 if (flag_branch_target_load_optimize)
3484 warning ("branch target register load optimization is not intended "
3487 open_dump_file (DFI_branch_target_load, decl);
3489 branch_target_load_optimize (insns, true);
3491 close_dump_file (DFI_branch_target_load, print_rtl_with_bb, insns);
3496 #ifdef INSN_SCHEDULING
3497 if (optimize > 0 && flag_schedule_insns_after_reload)
3498 rest_of_handle_sched2 (decl, insns);
3501 #ifdef LEAF_REGISTERS
3502 current_function_uses_only_leaf_regs
3503 = optimize > 0 && only_leaf_regs_used () && leaf_function_p ();
3507 rest_of_handle_stack_regs (decl, insns);
3510 compute_alignments ();
3512 /* CFG is no longer maintained up-to-date. */
3513 free_bb_for_insn ();
3515 if (targetm.machine_dependent_reorg != 0)
3516 rest_of_handle_machine_reorg (decl, insns);
3518 purge_line_number_notes (insns);
3519 cleanup_barriers ();
3522 if (optimize > 0 && flag_delayed_branch)
3523 rest_of_handle_delay_slots (decl, insns);
3526 #if defined (HAVE_ATTR_length) && !defined (STACK_REGS)
3527 timevar_push (TV_SHORTEN_BRANCH);
3528 split_all_insns_noflow ();
3529 timevar_pop (TV_SHORTEN_BRANCH);
3532 convert_to_eh_region_ranges ();
3534 /* Shorten branches. */
3535 timevar_push (TV_SHORTEN_BRANCH);
3536 shorten_branches (get_insns ());
3537 timevar_pop (TV_SHORTEN_BRANCH);
3539 set_nothrow_function_flags ();
3540 if (current_function_nothrow)
3541 /* Now we know that this can't throw; set the flag for the benefit
3542 of other functions later in this translation unit. */
3543 TREE_NOTHROW (current_function_decl) = 1;
3545 rest_of_handle_final (decl, insns);
3547 /* Write DBX symbols if requested. */
3549 /* Note that for those inline functions where we don't initially
3550 know for certain that we will be generating an out-of-line copy,
3551 the first invocation of this routine (rest_of_compilation) will
3552 skip over this code by doing a `goto exit_rest_of_compilation;'.
3553 Later on, wrapup_global_declarations will (indirectly) call
3554 rest_of_compilation again for those inline functions that need
3555 to have out-of-line copies generated. During that call, we
3556 *will* be routed past here. */
3558 timevar_push (TV_SYMOUT);
3559 (*debug_hooks->function_decl) (decl);
3560 timevar_pop (TV_SYMOUT);
3562 exit_rest_of_compilation:
3564 coverage_end_function ();
3566 /* In case the function was not output,
3567 don't leave any temporary anonymous types
3568 queued up for sdb output. */
3569 #ifdef SDB_DEBUGGING_INFO
3570 if (write_symbols == SDB_DEBUG)
3571 sdbout_types (NULL_TREE);
3574 reload_completed = 0;
3575 epilogue_completed = 0;
3576 flow2_completed = 0;
3579 timevar_push (TV_FINAL);
3581 /* Clear out the insn_length contents now that they are no
3583 init_insn_lengths ();
3585 /* Show no temporary slots allocated. */
3588 free_basic_block_vars (0);
3589 free_bb_for_insn ();
3591 timevar_pop (TV_FINAL);
3593 if ((*targetm.binds_local_p) (current_function_decl))
3595 int pref = cfun->preferred_stack_boundary;
3596 if (cfun->recursive_call_emit
3597 && cfun->stack_alignment_needed > cfun->preferred_stack_boundary)
3598 pref = cfun->stack_alignment_needed;
3599 cgraph_rtl_info (current_function_decl)->preferred_incoming_stack_boundary
3603 /* Make sure volatile mem refs aren't considered valid operands for
3604 arithmetic insns. We must call this here if this is a nested inline
3605 function, since the above code leaves us in the init_recog state
3606 (from final.c), and the function context push/pop code does not
3607 save/restore volatile_ok.
3609 ??? Maybe it isn't necessary for expand_start_function to call this
3610 anymore if we do it here? */
3612 init_recog_no_volatile ();
3614 /* We're done with this function. Free up memory if we can. */
3615 free_after_parsing (cfun);
3616 if (! DECL_DEFER_OUTPUT (decl))
3618 free_after_compilation (cfun);
3619 DECL_SAVED_INSNS (decl) = 0;
3625 timevar_pop (TV_REST_OF_COMPILATION);
3628 /* Display help for target options. */
3630 display_target_options (void)
3633 static bool displayed = false;
3635 /* Avoid double printing for --help --target-help. */
3641 if (ARRAY_SIZE (target_switches) > 1
3642 #ifdef TARGET_OPTIONS
3643 || ARRAY_SIZE (target_options) > 1
3651 printf (_("\nTarget specific options:\n"));
3653 for (i = ARRAY_SIZE (target_switches); i--;)
3655 const char *option = target_switches[i].name;
3656 const char *description = target_switches[i].description;
3658 if (option == NULL || *option == 0)
3660 else if (description == NULL)
3665 printf (_(" -m%-23s [undocumented]\n"), option);
3667 else if (*description != 0)
3668 doc += printf (" -m%-23s %s\n", option, _(description));
3671 #ifdef TARGET_OPTIONS
3672 for (i = ARRAY_SIZE (target_options); i--;)
3674 const char *option = target_options[i].prefix;
3675 const char *description = target_options[i].description;
3677 if (option == NULL || *option == 0)
3679 else if (description == NULL)
3684 printf (_(" -m%-23s [undocumented]\n"), option);
3686 else if (*description != 0)
3687 doc += printf (" -m%-23s %s\n", option, _(description));
3693 printf (_("\nThere are undocumented target specific options as well.\n"));
3695 printf (_(" They exist, but they are not documented.\n"));
3700 /* Parse a -d... command line switch. */
3703 decode_d_option (const char *arg)
3711 for (i = 0; i < (int) DFI_MAX; ++i)
3712 dump_file[i].enabled = 1;
3718 flag_print_asm_name = 1;
3721 flag_dump_rtl_in_asm = 1;
3722 flag_print_asm_name = 1;
3725 graph_dump_format = vcg;
3728 rtl_dump_and_exit = 1;
3733 case 'D': /* These are handled by the preprocessor. */
3737 setup_core_dumping();
3742 for (i = 0; i < (int) DFI_MAX; ++i)
3743 if (c == dump_file[i].debug_switch)
3745 dump_file[i].enabled = 1;
3750 warning ("unrecognized gcc debugging option: %c", c);
3755 /* Indexed by enum debug_info_type. */
3756 const char *const debug_type_names[] =
3758 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff", "vms"
3761 /* Decode -m switches. */
3762 /* Decode the switch -mNAME. */
3765 set_target_switch (const char *name)
3768 int valid_target_option = 0;
3770 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
3771 if (!strcmp (target_switches[j].name, name))
3773 if (target_switches[j].value < 0)
3774 target_flags &= ~-target_switches[j].value;
3776 target_flags |= target_switches[j].value;
3779 if (target_switches[j].value < 0)
3780 target_flags_explicit |= -target_switches[j].value;
3782 target_flags_explicit |= target_switches[j].value;
3784 valid_target_option = 1;
3787 #ifdef TARGET_OPTIONS
3788 if (!valid_target_option)
3789 for (j = 0; j < ARRAY_SIZE (target_options); j++)
3791 int len = strlen (target_options[j].prefix);
3792 if (target_options[j].value)
3794 if (!strcmp (target_options[j].prefix, name))
3796 *target_options[j].variable = target_options[j].value;
3797 valid_target_option = 1;
3802 if (!strncmp (target_options[j].prefix, name, len))
3804 *target_options[j].variable = name + len;
3805 valid_target_option = 1;
3811 if (!valid_target_option)
3812 error ("invalid option `%s'", name);
3815 /* Print version information to FILE.
3816 Each line begins with INDENT (for the case where FILE is the
3817 assembler output file). */
3820 print_version (FILE *file, const char *indent)
3823 #define __VERSION__ "[?]"
3827 "%s%s%s version %s (%s)\n%s\tcompiled by GNU C version %s.\n"
3829 "%s%s%s version %s (%s) compiled by CC.\n"
3831 , indent, *indent != 0 ? " " : "",
3832 lang_hooks.name, version_string, TARGET_NAME,
3833 indent, __VERSION__);
3834 fnotice (file, "%s%sGGC heuristics: --param ggc-min-expand=%d --param ggc-min-heapsize=%d\n",
3835 indent, *indent != 0 ? " " : "",
3836 PARAM_VALUE (GGC_MIN_EXPAND), PARAM_VALUE (GGC_MIN_HEAPSIZE));
3839 /* Print an option value and return the adjusted position in the line.
3840 ??? We don't handle error returns from fprintf (disk full); presumably
3841 other code will catch a disk full though. */
3844 print_single_switch (FILE *file, int pos, int max,
3845 const char *indent, const char *sep, const char *term,
3846 const char *type, const char *name)
3848 /* The ultrix fprintf returns 0 on success, so compute the result we want
3849 here since we need it for the following test. */
3850 int len = strlen (sep) + strlen (type) + strlen (name);
3855 fprintf (file, "%s", term);
3860 fprintf (file, "%s", indent);
3861 pos = strlen (indent);
3863 fprintf (file, "%s%s%s", sep, type, name);
3868 /* Print active target switches to FILE.
3869 POS is the current cursor position and MAX is the size of a "line".
3870 Each line begins with INDENT and ends with TERM.
3871 Each switch is separated from the next by SEP. */
3874 print_switch_values (FILE *file, int pos, int max,
3875 const char *indent, const char *sep, const char *term)
3880 /* Fill in the -frandom-seed option, if the user didn't pass it, so
3881 that it can be printed below. This helps reproducibility. */
3884 /* Print the options as passed. */
3885 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
3886 _("options passed: "), "");
3888 for (p = &save_argv[1]; *p != NULL; p++)
3892 if (strcmp (*p, "-o") == 0)
3898 if (strcmp (*p, "-quiet") == 0)
3900 if (strcmp (*p, "-version") == 0)
3905 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
3908 fprintf (file, "%s", term);
3910 /* Print the -f and -m options that have been enabled.
3911 We don't handle language specific options but printing argv
3914 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
3915 _("options enabled: "), "");
3917 for (j = 0; j < ARRAY_SIZE (f_options); j++)
3918 if (*f_options[j].variable == f_options[j].on_value)
3919 pos = print_single_switch (file, pos, max, indent, sep, term,
3920 "-f", f_options[j].string);
3922 /* Print target specific options. */
3924 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
3925 if (target_switches[j].name[0] != '\0'
3926 && target_switches[j].value > 0
3927 && ((target_switches[j].value & target_flags)
3928 == target_switches[j].value))
3930 pos = print_single_switch (file, pos, max, indent, sep, term,
3931 "-m", target_switches[j].name);
3934 #ifdef TARGET_OPTIONS
3935 for (j = 0; j < ARRAY_SIZE (target_options); j++)
3936 if (*target_options[j].variable != NULL)
3939 sprintf (prefix, "-m%s", target_options[j].prefix);
3940 pos = print_single_switch (file, pos, max, indent, sep, term,
3941 prefix, *target_options[j].variable);
3945 fprintf (file, "%s", term);
3948 /* Open assembly code output file. Do this even if -fsyntax-only is
3949 on, because then the driver will have provided the name of a
3950 temporary file or bit bucket for us. NAME is the file specified on
3951 the command line, possibly NULL. */
3953 init_asm_output (const char *name)
3955 if (name == NULL && asm_file_name == 0)
3956 asm_out_file = stdout;
3959 if (asm_file_name == 0)
3961 int len = strlen (dump_base_name);
3962 char *dumpname = xmalloc (len + 6);
3963 memcpy (dumpname, dump_base_name, len + 1);
3964 strip_off_ending (dumpname, len);
3965 strcat (dumpname, ".s");
3966 asm_file_name = dumpname;
3968 if (!strcmp (asm_file_name, "-"))
3969 asm_out_file = stdout;
3971 asm_out_file = fopen (asm_file_name, "w+");
3972 if (asm_out_file == 0)
3973 fatal_error ("can't open %s for writing: %m", asm_file_name);
3976 #ifdef IO_BUFFER_SIZE
3977 setvbuf (asm_out_file, xmalloc (IO_BUFFER_SIZE),
3978 _IOFBF, IO_BUFFER_SIZE);
3981 if (!flag_syntax_only)
3983 targetm.asm_out.file_start ();
3985 #ifdef ASM_COMMENT_START
3986 if (flag_verbose_asm)
3988 /* Print the list of options in effect. */
3989 print_version (asm_out_file, ASM_COMMENT_START);
3990 print_switch_values (asm_out_file, 0, MAX_LINE,
3991 ASM_COMMENT_START, " ", "\n");
3992 /* Add a blank line here so it appears in assembler output but not
3994 fprintf (asm_out_file, "\n");
4000 /* Default version of get_pch_validity.
4001 By default, every flag difference is fatal; that will be mostly right for
4002 most targets, but completely right for very few. */
4005 default_get_pch_validity (size_t *len)
4007 #ifdef TARGET_OPTIONS
4012 *len = sizeof (target_flags) + 2;
4013 #ifdef TARGET_OPTIONS
4014 for (i = 0; i < ARRAY_SIZE (target_options); i++)
4017 if (*target_options[i].variable)
4018 *len += strlen (*target_options[i].variable);
4022 result = r = xmalloc (*len);
4026 memcpy (r, &target_flags, sizeof (target_flags));
4027 r += sizeof (target_flags);
4029 #ifdef TARGET_OPTIONS
4030 for (i = 0; i < ARRAY_SIZE (target_options); i++)
4032 const char *str = *target_options[i].variable;
4036 l = strlen (str) + 1;
4045 /* Default version of pch_valid_p. */
4048 default_pch_valid_p (const void *data_p, size_t len)
4050 const char *data = (const char *)data_p;
4051 const char *flag_that_differs = NULL;
4054 /* -fpic and -fpie also usually make a PCH invalid. */
4055 if (data[0] != flag_pic)
4056 return _("created and used with different settings of -fpic");
4057 if (data[1] != flag_pie)
4058 return _("created and used with different settings of -fpie");
4061 /* Check target_flags. */
4062 if (memcmp (data, &target_flags, sizeof (target_flags)) != 0)
4064 for (i = 0; i < ARRAY_SIZE (target_switches); i++)
4069 memcpy (&tf, data, sizeof (target_flags));
4071 bits = target_switches[i].value;
4074 if ((target_flags & bits) != (tf & bits))
4076 flag_that_differs = target_switches[i].name;
4082 data += sizeof (target_flags);
4083 len -= sizeof (target_flags);
4085 /* Check string options. */
4086 #ifdef TARGET_OPTIONS
4087 for (i = 0; i < ARRAY_SIZE (target_options); i++)
4089 const char *str = *target_options[i].variable;
4093 l = strlen (str) + 1;
4094 if (len < l || memcmp (data, str, l) != 0)
4096 flag_that_differs = target_options[i].prefix;
4109 asprintf (&r, _("created and used with differing settings of `-m%s'"),
4112 return _("out of memory");
4117 /* Default tree printer. Handles declarations only. */
4119 default_tree_printer (pretty_printer * pp, text_info *text)
4121 switch (*text->format_spec)
4127 tree t = va_arg (*text->args_ptr, tree);
4128 const char *n = DECL_NAME (t)
4129 ? (*lang_hooks.decl_printable_name) (t, 2)
4140 /* Initialization of the front end environment, before command line
4141 options are parsed. Signal handlers, internationalization etc.
4142 ARGV0 is main's argv[0]. */
4144 general_init (const char *argv0)
4148 p = argv0 + strlen (argv0);
4149 while (p != argv0 && !IS_DIR_SEPARATOR (p[-1]))
4153 xmalloc_set_program_name (progname);
4157 gcc_init_libintl ();
4159 /* Initialize the diagnostics reporting machinery, so option parsing
4160 can give warnings and errors. */
4161 diagnostic_initialize (global_dc);
4162 /* Set a default printer. Language specific initializations will
4163 override it later. */
4164 pp_format_decoder (global_dc->printer) = &default_tree_printer;
4166 /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages. */
4168 signal (SIGSEGV, crash_signal);
4171 signal (SIGILL, crash_signal);
4174 signal (SIGBUS, crash_signal);
4177 signal (SIGABRT, crash_signal);
4179 #if defined SIGIOT && (!defined SIGABRT || SIGABRT != SIGIOT)
4180 signal (SIGIOT, crash_signal);
4183 signal (SIGFPE, crash_signal);
4186 /* Other host-specific signal setup. */
4187 (*host_hooks.extra_signals)();
4189 /* Initialize the garbage-collector, string pools and tree type hash
4195 /* Initialize register usage now so switches may override. */
4198 /* Register the language-independent parameters. */
4199 add_params (lang_independent_params, LAST_PARAM);
4201 /* This must be done after add_params but before argument processing. */
4202 init_ggc_heuristics();
4205 /* Process the options that have been parsed. */
4207 process_options (void)
4209 /* Allow the front end to perform consistency checks and do further
4210 initialization based on the command line options. This hook also
4211 sets the original filename if appropriate (e.g. foo.i -> foo.c)
4212 so we can correctly initialize debug output. */
4213 no_backend = (*lang_hooks.post_options) (&main_input_filename);
4214 input_filename = main_input_filename;
4216 #ifdef OVERRIDE_OPTIONS
4217 /* Some machines may reject certain combinations of options. */
4221 /* Set aux_base_name if not already set. */
4224 else if (main_input_filename)
4226 char *name = xstrdup (lbasename (main_input_filename));
4228 strip_off_ending (name, strlen (name));
4229 aux_base_name = name;
4232 aux_base_name = "gccaux";
4234 /* Set up the align_*_log variables, defaulting them to 1 if they
4235 were still unset. */
4236 if (align_loops <= 0) align_loops = 1;
4237 if (align_loops_max_skip > align_loops || !align_loops)
4238 align_loops_max_skip = align_loops - 1;
4239 align_loops_log = floor_log2 (align_loops * 2 - 1);
4240 if (align_jumps <= 0) align_jumps = 1;
4241 if (align_jumps_max_skip > align_jumps || !align_jumps)
4242 align_jumps_max_skip = align_jumps - 1;
4243 align_jumps_log = floor_log2 (align_jumps * 2 - 1);
4244 if (align_labels <= 0) align_labels = 1;
4245 align_labels_log = floor_log2 (align_labels * 2 - 1);
4246 if (align_labels_max_skip > align_labels || !align_labels)
4247 align_labels_max_skip = align_labels - 1;
4248 if (align_functions <= 0) align_functions = 1;
4249 align_functions_log = floor_log2 (align_functions * 2 - 1);
4251 /* Unrolling all loops implies that standard loop unrolling must also
4253 if (flag_unroll_all_loops)
4254 flag_unroll_loops = 1;
4256 if (flag_unroll_loops)
4258 flag_old_unroll_loops = 0;
4259 flag_old_unroll_all_loops = 0;
4262 if (flag_old_unroll_all_loops)
4263 flag_old_unroll_loops = 1;
4265 /* Old loop unrolling requires that strength_reduction be on also. Silently
4266 turn on strength reduction here if it isn't already on. Also, the loop
4267 unrolling code assumes that cse will be run after loop, so that must
4268 be turned on also. */
4269 if (flag_old_unroll_loops)
4271 flag_strength_reduce = 1;
4272 flag_rerun_cse_after_loop = 1;
4274 if (flag_unroll_loops || flag_peel_loops)
4275 flag_rerun_cse_after_loop = 1;
4277 if (flag_non_call_exceptions)
4278 flag_asynchronous_unwind_tables = 1;
4279 if (flag_asynchronous_unwind_tables)
4280 flag_unwind_tables = 1;
4282 /* Disable unit-at-a-time mode for frontends not supporting callgraph
4284 if (flag_unit_at_a_time && ! lang_hooks.callgraph.expand_function)
4285 flag_unit_at_a_time = 0;
4287 if (flag_value_profile_transformations)
4288 flag_profile_values = 1;
4290 /* Warn about options that are not supported on this machine. */
4291 #ifndef INSN_SCHEDULING
4292 if (flag_schedule_insns || flag_schedule_insns_after_reload)
4293 warning ("instruction scheduling not supported on this target machine");
4296 if (flag_delayed_branch)
4297 warning ("this target machine does not have delayed branches");
4300 user_label_prefix = USER_LABEL_PREFIX;
4301 if (flag_leading_underscore != -1)
4303 /* If the default prefix is more complicated than "" or "_",
4304 issue a warning and ignore this option. */
4305 if (user_label_prefix[0] == 0 ||
4306 (user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
4308 user_label_prefix = flag_leading_underscore ? "_" : "";
4311 warning ("-f%sleading-underscore not supported on this target machine",
4312 flag_leading_underscore ? "" : "no-");
4315 /* If we are in verbose mode, write out the version and maybe all the
4316 option flags in use. */
4319 print_version (stderr, "");
4321 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
4324 if (flag_syntax_only)
4326 write_symbols = NO_DEBUG;
4330 /* A lot of code assumes write_symbols == NO_DEBUG if the debugging
4332 if (debug_info_level == DINFO_LEVEL_NONE)
4333 write_symbols = NO_DEBUG;
4335 /* Now we know write_symbols, set up the debug hooks based on it.
4336 By default we do nothing for debug output. */
4337 if (write_symbols == NO_DEBUG)
4338 debug_hooks = &do_nothing_debug_hooks;
4339 #if defined(DBX_DEBUGGING_INFO)
4340 else if (write_symbols == DBX_DEBUG)
4341 debug_hooks = &dbx_debug_hooks;
4343 #if defined(XCOFF_DEBUGGING_INFO)
4344 else if (write_symbols == XCOFF_DEBUG)
4345 debug_hooks = &xcoff_debug_hooks;
4347 #ifdef SDB_DEBUGGING_INFO
4348 else if (write_symbols == SDB_DEBUG)
4349 debug_hooks = &sdb_debug_hooks;
4351 #ifdef DWARF_DEBUGGING_INFO
4352 else if (write_symbols == DWARF_DEBUG)
4353 debug_hooks = &dwarf_debug_hooks;
4355 #ifdef DWARF2_DEBUGGING_INFO
4356 else if (write_symbols == DWARF2_DEBUG)
4357 debug_hooks = &dwarf2_debug_hooks;
4359 #ifdef VMS_DEBUGGING_INFO
4360 else if (write_symbols == VMS_DEBUG || write_symbols == VMS_AND_DWARF2_DEBUG)
4361 debug_hooks = &vmsdbg_debug_hooks;
4364 error ("target system does not support the \"%s\" debug format",
4365 debug_type_names[write_symbols]);
4367 /* If auxiliary info generation is desired, open the output file.
4368 This goes in the same directory as the source file--unlike
4369 all the other output files. */
4370 if (flag_gen_aux_info)
4372 aux_info_file = fopen (aux_info_file_name, "w");
4373 if (aux_info_file == 0)
4374 fatal_error ("can't open %s: %m", aux_info_file_name);
4377 if (! targetm.have_named_sections)
4379 if (flag_function_sections)
4381 warning ("-ffunction-sections not supported for this target");
4382 flag_function_sections = 0;
4384 if (flag_data_sections)
4386 warning ("-fdata-sections not supported for this target");
4387 flag_data_sections = 0;
4391 if (flag_function_sections && profile_flag)
4393 warning ("-ffunction-sections disabled; it makes profiling impossible");
4394 flag_function_sections = 0;
4397 #ifndef HAVE_prefetch
4398 if (flag_prefetch_loop_arrays)
4400 warning ("-fprefetch-loop-arrays not supported for this target");
4401 flag_prefetch_loop_arrays = 0;
4404 if (flag_prefetch_loop_arrays && !HAVE_prefetch)
4406 warning ("-fprefetch-loop-arrays not supported for this target (try -march switches)");
4407 flag_prefetch_loop_arrays = 0;
4411 /* This combination of options isn't handled for i386 targets and doesn't
4412 make much sense anyway, so don't allow it. */
4413 if (flag_prefetch_loop_arrays && optimize_size)
4415 warning ("-fprefetch-loop-arrays is not supported with -Os");
4416 flag_prefetch_loop_arrays = 0;
4419 #ifndef OBJECT_FORMAT_ELF
4420 if (flag_function_sections && write_symbols != NO_DEBUG)
4421 warning ("-ffunction-sections may affect debugging on some targets");
4424 /* The presence of IEEE signaling NaNs, implies all math can trap. */
4425 if (flag_signaling_nans)
4426 flag_trapping_math = 1;
4429 /* Initialize the compiler back end. */
4433 init_adjust_machine_modes ();
4435 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
4436 || debug_info_level == DINFO_LEVEL_VERBOSE
4437 #ifdef VMS_DEBUGGING_INFO
4438 /* Enable line number info for traceback. */
4439 || debug_info_level > DINFO_LEVEL_NONE
4441 || flag_test_coverage
4442 || warn_notreached);
4445 init_fake_stack_mems ();
4449 init_function_once ();
4450 init_varasm_once ();
4452 /* The following initialization functions need to generate rtl, so
4453 provide a dummy function context for them. */
4454 init_dummy_function_start ();
4456 if (flag_caller_saves)
4457 init_caller_save ();
4458 expand_dummy_function_end ();
4461 /* Language-dependent initialization. Returns nonzero on success. */
4463 lang_dependent_init (const char *name)
4465 if (dump_base_name == 0)
4466 dump_base_name = name ? name : "gccdump";
4468 /* Other front-end initialization. */
4469 if ((*lang_hooks.init) () == 0)
4472 init_asm_output (name);
4474 /* These create various _DECL nodes, so need to be called after the
4475 front end is initialized. */
4479 /* The following initialization functions need to generate rtl, so
4480 provide a dummy function context for them. */
4481 init_dummy_function_start ();
4483 expand_dummy_function_end ();
4485 /* If dbx symbol table desired, initialize writing it and output the
4486 predefined types. */
4487 timevar_push (TV_SYMOUT);
4489 #ifdef DWARF2_UNWIND_INFO
4490 if (dwarf2out_do_frame ())
4491 dwarf2out_frame_init ();
4494 /* Now we have the correct original filename, we can initialize
4496 (*debug_hooks->init) (name);
4498 timevar_pop (TV_SYMOUT);
4503 /* Clean up: close opened files, etc. */
4508 /* Close the dump files. */
4509 if (flag_gen_aux_info)
4511 fclose (aux_info_file);
4513 unlink (aux_info_file_name);
4516 /* Close non-debugging input and output files. Take special care to note
4517 whether fclose returns an error, since the pages might still be on the
4518 buffer chain while the file is open. */
4522 if (ferror (asm_out_file) != 0)
4523 fatal_error ("error writing to %s: %m", asm_file_name);
4524 if (fclose (asm_out_file) != 0)
4525 fatal_error ("error closing %s: %m", asm_file_name);
4528 /* Do whatever is necessary to finish printing the graphs. */
4529 if (graph_dump_format != no_graph)
4533 for (i = 0; i < (int) DFI_MAX; ++i)
4534 if (dump_file[i].initialized && dump_file[i].graph_dump_p)
4539 sprintf (seq, DUMPFILE_FORMAT, i);
4540 suffix = concat (seq, dump_file[i].extension, NULL);
4541 finish_graph_dump_file (dump_base_name, suffix);
4548 ggc_print_statistics ();
4549 stringpool_statistics ();
4550 dump_tree_statistics ();
4553 /* Free up memory for the benefit of leak detectors. */
4556 /* Language-specific end of compilation actions. */
4557 (*lang_hooks.finish) ();
4560 /* Initialize the compiler, and compile the input file. */
4564 /* Initialize timing first. The C front ends read the main file in
4565 the post_options hook, and C++ does file timings. */
4566 if (time_report || !quiet_flag || flag_detailed_statistics)
4568 timevar_start (TV_TOTAL);
4572 /* Don't do any more if an error has already occurred. */
4575 /* Set up the back-end if requested. */
4579 /* Language-dependent initialization. Returns true on success. */
4580 if (lang_dependent_init (main_input_filename))
4582 if (flag_unit_at_a_time)
4584 open_dump_file (DFI_cgraph, NULL);
4585 cgraph_dump_file = rtl_dump_file;
4586 rtl_dump_file = NULL;
4591 if (flag_unit_at_a_time)
4593 rtl_dump_file = cgraph_dump_file;
4594 cgraph_dump_file = NULL;
4595 close_dump_file (DFI_cgraph, NULL, NULL_RTX);
4602 /* Stop timing and print the times. */
4603 timevar_stop (TV_TOTAL);
4604 timevar_print (stderr);
4607 /* Entry point of cc1, cc1plus, jc1, f771, etc.
4608 Exit code is FATAL_EXIT_CODE if can't open files or if there were
4609 any errors, or SUCCESS_EXIT_CODE if compilation succeeded.
4611 It is not safe to call this function more than once. */
4614 toplev_main (unsigned int argc, const char **argv)
4618 /* Initialization of GCC's environment, and diagnostics. */
4619 general_init (argv[0]);
4621 /* Parse the options and do minimal processing; basically just
4622 enough to default flags appropriately. */
4623 decode_options (argc, argv);
4627 /* Exit early if we can (e.g. -help). */
4628 if (!exit_after_options)
4631 if (errorcount || sorrycount)
4632 return (FATAL_EXIT_CODE);
4634 return (SUCCESS_EXIT_CODE);