1 /* Top level of GCC compilers (cc1, cc1plus, etc.)
2 Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 /* This is the top level of cc1/c++.
23 It parses command args, opens files, invokes the various passes
24 in the proper order, and counts the time used by each.
25 Error messages and low-level interface to malloc also handled here. */
28 #undef FLOAT /* This is for hpux. They should change hpux. */
29 #undef FFS /* Some systems define this in param.h. */
31 #include "coretypes.h"
35 #ifdef HAVE_SYS_RESOURCE_H
36 # include <sys/resource.h>
39 #ifdef HAVE_SYS_TIMES_H
40 # include <sys/times.h>
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"
81 #include "alloc-pool.h"
83 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
84 #include "dwarf2out.h"
87 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
91 #ifdef SDB_DEBUGGING_INFO
95 #ifdef XCOFF_DEBUGGING_INFO
96 #include "xcoffout.h" /* Needed for external data
97 declarations for e.g. AIX 4.x. */
100 #ifndef HAVE_conditional_execution
101 #define HAVE_conditional_execution 0
104 /* Carry information from ASM_DECLARE_OBJECT_NAME
105 to ASM_FINISH_DECLARE_OBJECT. */
107 extern int size_directive_output;
108 extern tree last_assemble_variable_decl;
110 extern void reg_alloc (void);
112 static void general_init (const char *);
113 static void do_compile (void);
114 static void process_options (void);
115 static void backend_init (void);
116 static int lang_dependent_init (const char *);
117 static void init_asm_output (const char *);
118 static void finalize (void);
120 static void crash_signal (int) ATTRIBUTE_NORETURN;
121 static void setup_core_dumping (void);
122 static void compile_file (void);
124 static int print_single_switch (FILE *, int, int, const char *,
125 const char *, const char *,
126 const char *, const char *);
127 static void print_switch_values (FILE *, int, int, const char *,
128 const char *, const char *);
130 /* Rest of compilation helper functions. */
131 static bool rest_of_handle_inlining (tree);
132 static void rest_of_handle_cse (tree, rtx);
133 static void rest_of_handle_cse2 (tree, rtx);
134 static void rest_of_handle_gcse (tree, rtx);
135 static void rest_of_handle_life (tree, rtx);
136 static void rest_of_handle_loop_optimize (tree, rtx);
137 static void rest_of_handle_loop2 (tree, rtx);
138 static void rest_of_handle_jump_bypass (tree, rtx);
139 static void rest_of_handle_sibling_calls (rtx);
140 static void rest_of_handle_null_pointer (tree, rtx);
141 static void rest_of_handle_addressof (tree, rtx);
142 static void rest_of_handle_cfg (tree, rtx);
143 static void rest_of_handle_branch_prob (tree, rtx);
144 static void rest_of_handle_value_profile_transformations (tree, rtx);
145 static void rest_of_handle_if_conversion (tree, rtx);
146 static void rest_of_handle_if_after_combine (tree, rtx);
147 static void rest_of_handle_tracer (tree, rtx);
148 static void rest_of_handle_combine (tree, rtx);
149 static void rest_of_handle_regmove (tree, rtx);
150 #ifdef INSN_SCHEDULING
151 static void rest_of_handle_sched (tree, rtx);
152 static void rest_of_handle_sched2 (tree, rtx);
154 static bool rest_of_handle_new_regalloc (tree, rtx);
155 static bool rest_of_handle_old_regalloc (tree, rtx);
156 static void rest_of_handle_regrename (tree, rtx);
157 static void rest_of_handle_reorder_blocks (tree, rtx);
159 static void rest_of_handle_stack_regs (tree, rtx);
161 static void rest_of_handle_variable_tracking (tree, rtx);
162 static void rest_of_handle_machine_reorg (tree, rtx);
164 static void rest_of_handle_delay_slots (tree, rtx);
166 static void rest_of_handle_final (tree, rtx);
168 /* Nonzero to dump debug info whilst parsing (-dy option). */
169 static int set_yydebug;
171 /* True if we don't need a backend (e.g. preprocessing only). */
172 static bool no_backend;
174 /* Length of line when printing switch values. */
177 /* Name of program invoked, sans directories. */
179 const char *progname;
181 /* Copy of argument vector to toplev_main. */
182 static const char **save_argv;
184 /* Name of top-level original source file (what was input to cpp).
185 This comes from the #-command at the beginning of the actual input.
186 If there isn't any there, then this is the cc1 input file name. */
188 const char *main_input_filename;
190 /* Current position in real source file. */
192 location_t input_location;
194 struct line_maps line_table;
196 /* Nonzero if it is unsafe to create any new pseudo registers. */
199 /* Stack of currently pending input files. */
201 struct file_stack *input_file_stack;
203 /* Incremented on each change to input_file_stack. */
204 int input_file_stack_tick;
206 /* Name to use as base of names for dump output files. */
208 const char *dump_base_name;
210 /* Name to use as a base for auxiliary output files. */
212 const char *aux_base_name;
214 /* Format to use to print dumpfile index value */
215 #ifndef DUMPFILE_FORMAT
216 #define DUMPFILE_FORMAT ".%02d."
219 /* Bit flags that specify the machine subtype we are compiling for.
220 Bits are tested using macros TARGET_... defined in the tm.h file
221 and set by `-m...' switches. Must be defined in rtlanal.c. */
223 extern int target_flags;
225 /* A mask of target_flags that includes bit X if X was set or cleared
226 on the command line. */
228 int target_flags_explicit;
230 /* Debug hooks - dependent upon command line options. */
232 const struct gcc_debug_hooks *debug_hooks;
234 /* Describes a dump file. */
236 struct dump_file_info
238 /* The unique extension to apply, e.g. ".jump". */
239 const char *const extension;
241 /* The -d<c> character that enables this dump file. */
242 char const debug_switch;
244 /* True if there is a corresponding graph dump file. */
245 char const graph_dump_p;
247 /* True if the user selected this dump. */
250 /* True if the files have been initialized (ie truncated). */
254 /* Enumerate the extant dump files. */
290 DFI_branch_target_load,
299 /* Describes all the dump files. Should be kept in order of the
300 pass and in sync with dump_file_index above.
302 Remaining -d letters:
308 static struct dump_file_info dump_file[DFI_MAX] =
310 { "cgraph", 'U', 0, 0, 0 },
311 { "rtl", 'r', 0, 0, 0 },
312 { "sibling", 'i', 0, 0, 0 },
313 { "eh", 'h', 0, 0, 0 },
314 { "jump", 'j', 0, 0, 0 },
315 { "null", 'u', 0, 0, 0 },
316 { "cse", 's', 0, 0, 0 },
317 { "addressof", 'F', 0, 0, 0 },
318 { "gcse", 'G', 1, 0, 0 },
319 { "loop", 'L', 1, 0, 0 },
320 { "bypass", 'G', 1, 0, 0 }, /* Yes, duplicate enable switch. */
321 { "cfg", 'f', 1, 0, 0 },
322 { "bp", 'b', 1, 0, 0 },
323 { "vpt", 'V', 1, 0, 0 },
324 { "ce1", 'C', 1, 0, 0 },
325 { "tracer", 'T', 1, 0, 0 },
326 { "loop2", 'L', 1, 0, 0 },
327 { "web", 'Z', 0, 0, 0 },
328 { "cse2", 't', 1, 0, 0 },
329 { "life", 'f', 1, 0, 0 }, /* Yes, duplicate enable switch. */
330 { "combine", 'c', 1, 0, 0 },
331 { "ce2", 'C', 1, 0, 0 },
332 { "regmove", 'N', 1, 0, 0 },
333 { "sched", 'S', 1, 0, 0 },
334 { "lreg", 'l', 1, 0, 0 },
335 { "greg", 'g', 1, 0, 0 },
336 { "postreload", 'o', 1, 0, 0 },
337 { "flow2", 'w', 1, 0, 0 },
338 { "peephole2", 'z', 1, 0, 0 },
339 { "rnreg", 'n', 1, 0, 0 },
340 { "ce3", 'E', 1, 0, 0 },
341 { "bbro", 'B', 1, 0, 0 },
342 { "btl", 'd', 1, 0, 0 }, /* Yes, duplicate enable switch. */
343 { "sched2", 'R', 1, 0, 0 },
344 { "stack", 'k', 1, 0, 0 },
345 { "vartrack", 'V', 1, 0, 0 }, /* Yes, duplicate enable switch. */
346 { "mach", 'M', 1, 0, 0 },
347 { "dbr", 'd', 0, 0, 0 },
350 static int open_dump_file (enum dump_file_index, tree);
351 static void close_dump_file (enum dump_file_index,
352 void (*) (FILE *, rtx), rtx);
354 /* Other flags saying which kinds of debugging dump have been requested. */
356 int rtl_dump_and_exit;
357 int flag_print_asm_name;
358 enum graph_dump_types graph_dump_format;
360 /* Name for output file of assembly code, specified with -o. */
362 const char *asm_file_name;
364 /* Nonzero means do optimizations. -O.
365 Particular numeric values stand for particular amounts of optimization;
366 thus, -O2 stores 2 here. However, the optimizations beyond the basic
367 ones are not controlled directly by this variable. Instead, they are
368 controlled by individual `flag_...' variables that are defaulted
369 based on this variable. */
373 /* Nonzero means optimize for size. -Os.
374 The only valid values are zero and nonzero. When optimize_size is
375 nonzero, optimize defaults to 2, but certain individual code
376 bloating optimizations are disabled. */
378 int optimize_size = 0;
380 /* The FUNCTION_DECL for the function currently being compiled,
381 or 0 if between functions. */
382 tree current_function_decl;
384 /* Set to the FUNC_BEGIN label of the current function, or NULL_TREE
386 tree current_function_func_begin_label;
388 /* Nonzero if doing dwarf2 duplicate elimination. */
390 int flag_eliminate_dwarf2_dups = 0;
392 /* Nonzero if doing unused type elimination. */
394 int flag_eliminate_unused_debug_types = 1;
396 /* Nonzero means emit debugging information only for symbols which are used. */
397 int flag_debug_only_used_symbols = 0;
399 /* Nonzero if generating code to do profiling. */
401 int profile_flag = 0;
403 /* Nonzero if generating code to profile program flow graph arcs. */
405 int profile_arc_flag = 0;
407 /* Nonzero if value histograms should be measured. */
409 int flag_profile_values = 0;
411 /* Nonzero if value histograms should be used to optimize code. */
412 int flag_value_profile_transformations = 0;
414 /* Nonzero if generating info for gcov to calculate line test coverage. */
416 int flag_test_coverage = 0;
418 /* Nonzero indicates that branch taken probabilities should be calculated. */
420 int flag_branch_probabilities = 0;
422 /* Nonzero if basic blocks should be reordered. */
424 int flag_reorder_blocks = 0;
426 /* Nonzero if functions should be reordered. */
428 int flag_reorder_functions = 0;
430 /* Nonzero if registers should be renamed. */
432 int flag_rename_registers = 0;
433 int flag_cprop_registers = 0;
435 /* Nonzero for -pedantic switch: warn about anything
436 that standard spec forbids. */
440 /* Temporarily suppress certain warnings.
441 This is set while reading code from a system header file. */
443 int in_system_header = 0;
445 /* Don't print functions as they are compiled. -quiet. */
449 /* Print times taken by the various passes. -ftime-report. */
453 /* Print memory still in use at end of compilation (which may have little
454 to do with peak memory consumption). -fmem-report. */
458 /* Nonzero means to collect statistics which might be expensive
459 and to print them when we are done. */
460 int flag_detailed_statistics = 0;
462 /* A random sequence of characters, unless overridden by user. */
463 const char *flag_random_seed;
465 /* A local time stamp derived from the time of compilation. It will be
466 zero if the system cannot provide a time. It will be -1u, if the
467 user has specified a particular random seed. */
472 /* Nonzero means `char' should be signed. */
474 int flag_signed_char;
476 /* Nonzero means give an enum type only as many bytes as it needs. */
478 int flag_short_enums;
480 /* Nonzero for -fcaller-saves: allocate values in regs that need to
481 be saved across function calls, if that produces overall better code.
482 Optional now, so people can test it. */
484 int flag_caller_saves = 0;
486 /* Nonzero if structures and unions should be returned in memory.
488 This should only be defined if compatibility with another compiler or
489 with an ABI is needed, because it results in slower code. */
491 #ifndef DEFAULT_PCC_STRUCT_RETURN
492 #define DEFAULT_PCC_STRUCT_RETURN 1
495 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
497 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
499 /* Nonzero for -fforce-mem: load memory value into a register
500 before arithmetic on it. This makes better cse but slower compilation. */
502 int flag_force_mem = 0;
504 /* Nonzero for -fforce-addr: load memory address into a register before
505 reference to memory. This makes better cse but slower compilation. */
507 int flag_force_addr = 0;
509 /* Nonzero for -fdefer-pop: don't pop args after each function call;
510 instead save them up to pop many calls' args with one insns. */
512 int flag_defer_pop = 0;
514 /* Nonzero for -ffloat-store: don't allocate floats and doubles
515 in extended-precision registers. */
517 int flag_float_store = 0;
519 /* Nonzero for -fcse-follow-jumps:
520 have cse follow jumps to do a more extensive job. */
522 int flag_cse_follow_jumps;
524 /* Nonzero for -fcse-skip-blocks:
525 have cse follow a branch around a block. */
526 int flag_cse_skip_blocks;
528 /* Nonzero for -fexpensive-optimizations:
529 perform miscellaneous relatively-expensive optimizations. */
530 int flag_expensive_optimizations;
532 /* Nonzero for -fthread-jumps:
533 have jump optimize output of loop. */
535 int flag_thread_jumps;
537 /* Nonzero enables strength-reduction in loop.c. */
539 int flag_strength_reduce = 0;
541 /* Nonzero enables loop unrolling in unroll.c. Only loops for which the
542 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY,
543 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are
546 int flag_old_unroll_loops;
548 /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled.
549 This is generally not a win. */
551 int flag_old_unroll_all_loops;
553 /* Enables unrolling of simple loops in loop-unroll.c. */
554 int flag_unroll_loops;
556 /* Enables unrolling of all loops in loop-unroll.c. */
557 int flag_unroll_all_loops;
559 /* Nonzero enables loop peeling. */
562 /* Nonzero enables loop unswitching. */
563 int flag_unswitch_loops;
565 /* Nonzero enables prefetch optimizations for arrays in loops. */
567 int flag_prefetch_loop_arrays;
569 /* Nonzero forces all invariant computations in loops to be moved
572 int flag_move_all_movables = 0;
574 /* Nonzero forces all general induction variables in loops to be
577 int flag_reduce_all_givs = 0;
579 /* Nonzero to perform full register move optimization passes. This is the
582 int flag_regmove = 0;
584 /* Nonzero for -fwritable-strings:
585 store string constants in data segment and don't uniquize them. */
587 int flag_writable_strings = 0;
589 /* Nonzero means don't put addresses of constant functions in registers.
590 Used for compiling the Unix kernel, where strange substitutions are
591 done on the assembly output. */
593 int flag_no_function_cse = 0;
595 /* Nonzero for -fomit-frame-pointer:
596 don't make a frame pointer in simple functions that don't require one. */
598 int flag_omit_frame_pointer = 0;
600 /* Nonzero means place each function into its own section on those platforms
601 which support arbitrary section names and unlimited numbers of sections. */
603 int flag_function_sections = 0;
605 /* ... and similar for data. */
607 int flag_data_sections = 0;
609 /* Nonzero to inhibit use of define_optimization peephole opts. */
611 int flag_no_peephole = 0;
613 /* Nonzero allows GCC to optimize sibling and tail recursive calls. */
615 int flag_optimize_sibling_calls = 0;
617 /* Nonzero means the front end generally wants `errno' maintained by math
618 operations, like built-in SQRT. */
620 int flag_errno_math = 1;
622 /* Nonzero means that unsafe floating-point math optimizations are allowed
623 for the sake of speed. IEEE compliance is not guaranteed, and operations
624 are allowed to assume that their arguments and results are "normal"
625 (e.g., nonnegative for SQRT). */
627 int flag_unsafe_math_optimizations = 0;
629 /* Nonzero means that no NaNs or +-Infs are expected. */
631 int flag_finite_math_only = 0;
633 /* Zero means that floating-point math operations cannot generate a
634 (user-visible) trap. This is the case, for example, in nonstop
635 IEEE 754 arithmetic. Trapping conditions include division by zero,
636 overflow, underflow, invalid and inexact, but does not include
637 operations on signaling NaNs (see below). */
639 int flag_trapping_math = 1;
641 /* Nonzero means disable transformations that assume default floating
642 point rounding behavior. */
644 int flag_rounding_math = 0;
646 /* Nonzero means disable transformations observable by signaling NaNs.
647 This option implies that any operation on an IEEE signaling NaN can
648 generate a (user-visible) trap. */
650 int flag_signaling_nans = 0;
652 /* 0 means straightforward implementation of complex divide acceptable.
653 1 means wide ranges of inputs must work for complex divide.
654 2 means C99-like requirements for complex divide (not yet implemented). */
656 int flag_complex_divide_method = 0;
658 /* Nonzero means just do syntax checking; don't output anything. */
660 int flag_syntax_only = 0;
662 /* Nonzero means performs web construction pass. */
666 /* Nonzero means perform loop optimizer. */
668 int flag_loop_optimize;
670 /* Nonzero means perform crossjumping. */
672 int flag_crossjumping;
674 /* Nonzero means perform if conversion. */
676 int flag_if_conversion;
678 /* Nonzero means perform if conversion after reload. */
680 int flag_if_conversion2;
682 /* Nonzero means to use global dataflow analysis to eliminate
683 useless null pointer tests. */
685 int flag_delete_null_pointer_checks;
687 /* Nonzero means perform global CSE. */
691 /* Nonzero means to do the enhanced load motion during gcse, which trys
692 to hoist loads by not killing them when a store to the same location
695 int flag_gcse_lm = 1;
697 /* Nonzero means to perform store motion after gcse, which will try to
698 move stores closer to the exit block. Its not very effective without
701 int flag_gcse_sm = 1;
703 /* Nonzero if we want to perfrom redundant load after store elimination
706 int flag_gcse_las = 1;
708 /* Perform target register optimization before prologue / epilogue
711 int flag_branch_target_load_optimize = 0;
713 /* Perform target register optimization after prologue / epilogue
714 threading and jump2. */
716 int flag_branch_target_load_optimize2 = 0;
718 /* For the bt-load pass, nonzero means don't re-use branch target registers
719 in any basic block. */
721 int flag_btr_bb_exclusive;
723 /* Nonzero means to rerun cse after loop optimization. This increases
724 compilation time about 20% and picks up a few more common expressions. */
726 int flag_rerun_cse_after_loop;
728 /* Nonzero means to run loop optimizations twice. */
730 int flag_rerun_loop_opt;
732 /* Nonzero for -finline-functions: ok to inline functions that look like
733 good inline candidates. */
735 int flag_inline_functions;
737 /* Nonzero for -fkeep-inline-functions: even if we make a function
738 go inline everywhere, keep its definition around for debugging
741 int flag_keep_inline_functions;
743 /* Nonzero means that functions will not be inlined. */
745 int flag_no_inline = 2;
747 /* Nonzero means that we don't want inlining by virtue of -fno-inline,
748 not just because the tree inliner turned us off. */
750 int flag_really_no_inline = 2;
752 /* Nonzero means that we should emit static const variables
753 regardless of whether or not optimization is turned on. */
755 int flag_keep_static_consts = 1;
757 /* Nonzero means we should be saving declaration info into a .X file. */
759 int flag_gen_aux_info = 0;
761 /* Specified name of aux-info file. */
763 const char *aux_info_file_name;
765 /* Nonzero means make the text shared if supported. */
767 int flag_shared_data;
769 /* Nonzero means schedule into delayed branch slots if supported. */
771 int flag_delayed_branch;
773 /* Nonzero if we are compiling pure (sharable) code.
774 Value is 1 if we are doing "small" pic; value is 2 if we're doing
779 /* Nonzero if we are compiling position independent code for executable.
780 The value is 1 if we are doing "small" pic; value is 2 if we're doing
785 /* Nonzero if we are compiling code for a shared library, zero for
790 /* Set to the default thread-local storage (tls) model to use. */
792 enum tls_model flag_tls_default = TLS_MODEL_GLOBAL_DYNAMIC;
794 /* Nonzero means generate extra code for exception handling and enable
795 exception handling. */
799 /* Nonzero means generate frame unwind info table when supported. */
801 int flag_unwind_tables = 0;
803 /* Nonzero means generate frame unwind info table exact at each insn
806 int flag_asynchronous_unwind_tables = 0;
808 /* Nonzero means don't place uninitialized global data in common storage
813 /* Nonzero means change certain warnings into errors.
814 Usually these are warnings about failure to conform to some standard. */
816 int flag_pedantic_errors = 0;
818 /* flag_schedule_insns means schedule insns within basic blocks (before
820 flag_schedule_insns_after_reload means schedule insns after
823 int flag_schedule_insns = 0;
824 int flag_schedule_insns_after_reload = 0;
826 /* When flag_schedule_insns_after_reload is set, use EBB scheduler. */
827 int flag_sched2_use_superblocks = 0;
829 /* When flag_schedule_insns_after_reload is set, construct traces and EBB
831 int flag_sched2_use_traces = 0;
833 /* The following flags have effect only for scheduling before register
836 flag_schedule_interblock means schedule insns across basic blocks.
837 flag_schedule_speculative means allow speculative motion of non-load insns.
838 flag_schedule_speculative_load means allow speculative motion of some
840 flag_schedule_speculative_load_dangerous allows speculative motion of more
843 int flag_schedule_interblock = 1;
844 int flag_schedule_speculative = 1;
845 int flag_schedule_speculative_load = 0;
846 int flag_schedule_speculative_load_dangerous = 0;
848 /* The following flags have an effect during scheduling after register
851 flag_sched_stalled_insns means that insns can be moved prematurely from the queue
852 of stalled insns into the ready list.
854 flag_sched_stalled_insns_dep controls how many insn groups will be examined
855 for a dependency on a stalled insn that is candidate for premature removal
856 from the queue of stalled insns into the ready list (has an effect only if
857 the flag 'sched_stalled_insns' is set). */
859 int flag_sched_stalled_insns = 0;
860 int flag_sched_stalled_insns_dep = 1;
862 int flag_single_precision_constant;
864 /* flag_branch_on_count_reg means try to replace add-1,compare,branch tupple
865 by a cheaper branch on a count register. */
866 int flag_branch_on_count_reg = 1;
868 /* -finhibit-size-directive inhibits output of .size for ELF.
869 This is used only for compiling crtstuff.c,
870 and it may be extended to other effects
871 needed for crtstuff.c on other systems. */
872 int flag_inhibit_size_directive = 0;
874 /* -fverbose-asm causes extra commentary information to be produced in
875 the generated assembly code (to make it more readable). This option
876 is generally only of use to those who actually need to read the
877 generated assembly code (perhaps while debugging the compiler itself).
878 -fno-verbose-asm, the default, causes the extra information
879 to be omitted and is useful when comparing two assembler files. */
881 int flag_verbose_asm = 0;
883 /* -dA causes debug commentary information to be produced in
884 the generated assembly code (to make it more readable). This option
885 is generally only of use to those who actually need to read the
886 generated assembly code (perhaps while debugging the compiler itself).
887 Currently, this switch is only used by dwarfout.c; however, it is intended
888 to be a catchall for printing debug information in the assembler file. */
890 int flag_debug_asm = 0;
892 /* -dP causes the rtl to be emitted as a comment in assembly. */
894 int flag_dump_rtl_in_asm = 0;
896 /* Nonzero means put zero initialized data in the bss section. */
897 int flag_zero_initialized_in_bss = 1;
899 /* Tag all structures with __attribute__(packed). */
900 int flag_pack_struct = 0;
902 /* Emit code to check for stack overflow; also may cause large objects
903 to be allocated dynamically. */
904 int flag_stack_check;
906 /* When non-NULL, indicates that whenever space is allocated on the
907 stack, the resulting stack pointer must not pass this
908 address---that is, for stacks that grow downward, the stack pointer
909 must always be greater than or equal to this address; for stacks
910 that grow upward, the stack pointer must be less than this address.
911 At present, the rtx may be either a REG or a SYMBOL_REF, although
912 the support provided depends on the backend. */
915 /* 0 if pointer arguments may alias each other. True in C.
916 1 if pointer arguments may not alias each other but may alias
918 2 if pointer arguments may not alias each other and may not
919 alias global variables. True in Fortran.
920 This defaults to 0 for C. */
921 int flag_argument_noalias = 0;
923 /* Nonzero if we should do (language-dependent) alias analysis.
924 Typically, this analysis will assume that expressions of certain
925 types do not alias expressions of certain other types. Only used
926 if alias analysis (in general) is enabled. */
927 int flag_strict_aliasing = 0;
929 /* Instrument functions with calls at entry and exit, for profiling. */
930 int flag_instrument_function_entry_exit = 0;
932 /* Nonzero means ignore `#ident' directives. 0 means handle them.
933 On SVR4 targets, it also controls whether or not to emit a
934 string identifying the compiler. */
936 int flag_no_ident = 0;
938 /* This will perform a peephole pass before sched2. */
939 int flag_peephole2 = 0;
941 /* This will try to guess branch probabilities. */
942 int flag_guess_branch_prob = 0;
944 /* -fcheck-bounds causes gcc to generate array bounds checks.
945 For C, C++, ObjC: defaults to off.
946 For Java: defaults to on.
947 For Fortran: defaults to off. */
948 int flag_bounds_check = 0;
950 /* This will attempt to merge constant section constants, if 1 only
951 string constants and constants from constant pool, if 2 also constant
953 int flag_merge_constants = 1;
955 /* If one, renumber instruction UIDs to reduce the number of
956 unused UIDs if there are a lot of instructions. If greater than
957 one, unconditionally renumber instruction UIDs. */
958 int flag_renumber_insns = 1;
960 /* If nonzero, use the graph coloring register allocator. */
961 int flag_new_regalloc = 0;
963 /* Nonzero if we perform superblock formation. */
967 /* Nonzero if we perform whole unit at a time compilation. */
969 int flag_unit_at_a_time = 0;
971 /* Nonzero if we should track variables. When
972 flag_var_tracking == AUTODETECT_FLAG_VAR_TRACKING it will be set according
973 to optimize, debug_info_level and debug_hooks in process_options (). */
975 #define AUTODETECT_FLAG_VAR_TRACKING 2
976 int flag_var_tracking = AUTODETECT_FLAG_VAR_TRACKING;
978 /* Values of the -falign-* flags: how much to align labels in code.
979 0 means `use default', 1 means `don't align'.
980 For each variable, there is an _log variant which is the power
981 of two not less than the variable, for .align output. */
985 int align_loops_max_skip;
988 int align_jumps_max_skip;
990 int align_labels_log;
991 int align_labels_max_skip;
993 int align_functions_log;
995 /* Like align_functions_log above, but used by front-ends to force the
996 minimum function alignment. Zero means no alignment is forced. */
997 int force_align_functions_log;
1001 const char *const string;
1002 int *const variable;
1005 lang_independent_options;
1007 /* Nonzero if signed arithmetic overflow should trap. */
1010 /* Nonzero if signed arithmetic overflow should wrap around. */
1013 /* Nonzero if subexpressions must be evaluated from left-to-right. */
1014 int flag_evaluation_order = 0;
1016 /* Add or remove a leading underscore from user symbols. */
1017 int flag_leading_underscore = -1;
1019 /* The version of the C++ ABI in use. The following values are
1022 0: The version of the ABI believed most conformant with the
1023 C++ ABI specification. This ABI may change as bugs are
1024 discovered and fixed. Therefore, 0 will not necessarily
1025 indicate the same ABI in different versions of G++.
1027 1: The version of the ABI first used in G++ 3.2.
1029 2: The version of the ABI first used in G++ 3.4.
1031 Additional positive integers will be assigned as new versions of
1032 the ABI become the default version of the ABI. */
1034 int flag_abi_version = 2;
1036 /* The user symbol prefix after having resolved same. */
1037 const char *user_label_prefix;
1039 static const param_info lang_independent_params[] = {
1040 #define DEFPARAM(ENUM, OPTION, HELP, DEFAULT) \
1041 { OPTION, DEFAULT, HELP },
1042 #include "params.def"
1047 /* Table of language-independent -f options.
1048 STRING is the option name. VARIABLE is the address of the variable.
1049 ON_VALUE is the value to store in VARIABLE
1050 if `-fSTRING' is seen as an option.
1051 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
1053 static const lang_independent_options f_options[] =
1055 {"eliminate-dwarf2-dups", &flag_eliminate_dwarf2_dups, 1 },
1056 {"eliminate-unused-debug-symbols", &flag_debug_only_used_symbols, 1 },
1057 {"eliminate-unused-debug-types", &flag_eliminate_unused_debug_types, 1 },
1058 {"float-store", &flag_float_store, 1 },
1059 {"defer-pop", &flag_defer_pop, 1 },
1060 {"omit-frame-pointer", &flag_omit_frame_pointer, 1 },
1061 {"optimize-sibling-calls", &flag_optimize_sibling_calls, 1 },
1062 {"tracer", &flag_tracer, 1 },
1063 {"unit-at-a-time", &flag_unit_at_a_time, 1 },
1064 {"cse-follow-jumps", &flag_cse_follow_jumps, 1 },
1065 {"cse-skip-blocks", &flag_cse_skip_blocks, 1 },
1066 {"expensive-optimizations", &flag_expensive_optimizations, 1 },
1067 {"thread-jumps", &flag_thread_jumps, 1 },
1068 {"strength-reduce", &flag_strength_reduce, 1 },
1069 {"unroll-loops", &flag_unroll_loops, 1 },
1070 {"unroll-all-loops", &flag_unroll_all_loops, 1 },
1071 {"old-unroll-loops", &flag_old_unroll_loops, 1 },
1072 {"old-unroll-all-loops", &flag_old_unroll_all_loops, 1 },
1073 {"peel-loops", &flag_peel_loops, 1 },
1074 {"unswitch-loops", &flag_unswitch_loops, 1 },
1075 {"prefetch-loop-arrays", &flag_prefetch_loop_arrays, 1 },
1076 {"move-all-movables", &flag_move_all_movables, 1 },
1077 {"reduce-all-givs", &flag_reduce_all_givs, 1 },
1078 {"writable-strings", &flag_writable_strings, 1 },
1079 {"peephole", &flag_no_peephole, 0 },
1080 {"force-mem", &flag_force_mem, 1 },
1081 {"force-addr", &flag_force_addr, 1 },
1082 {"function-cse", &flag_no_function_cse, 0 },
1083 {"inline-functions", &flag_inline_functions, 1 },
1084 {"keep-inline-functions", &flag_keep_inline_functions, 1 },
1085 {"inline", &flag_no_inline, 0 },
1086 {"keep-static-consts", &flag_keep_static_consts, 1 },
1087 {"syntax-only", &flag_syntax_only, 1 },
1088 {"shared-data", &flag_shared_data, 1 },
1089 {"caller-saves", &flag_caller_saves, 1 },
1090 {"pcc-struct-return", &flag_pcc_struct_return, 1 },
1091 {"reg-struct-return", &flag_pcc_struct_return, 0 },
1092 {"delayed-branch", &flag_delayed_branch, 1 },
1093 {"web", &flag_web, 1},
1094 {"gcse", &flag_gcse, 1 },
1095 {"gcse-lm", &flag_gcse_lm, 1 },
1096 {"gcse-sm", &flag_gcse_sm, 1 },
1097 {"gcse-las", &flag_gcse_las, 1 },
1098 {"branch-target-load-optimize", &flag_branch_target_load_optimize, 1 },
1099 {"branch-target-load-optimize2", &flag_branch_target_load_optimize2, 1 },
1100 {"btr-bb-exclusive", &flag_btr_bb_exclusive, 1 },
1101 {"loop-optimize", &flag_loop_optimize, 1 },
1102 {"crossjumping", &flag_crossjumping, 1 },
1103 {"if-conversion", &flag_if_conversion, 1 },
1104 {"if-conversion2", &flag_if_conversion2, 1 },
1105 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1 },
1106 {"rerun-loop-opt", &flag_rerun_loop_opt, 1 },
1107 {"delete-null-pointer-checks", &flag_delete_null_pointer_checks, 1 },
1108 {"schedule-insns", &flag_schedule_insns, 1 },
1109 {"schedule-insns2", &flag_schedule_insns_after_reload, 1 },
1110 {"sched-interblock",&flag_schedule_interblock, 1 },
1111 {"sched-spec",&flag_schedule_speculative, 1 },
1112 {"sched-spec-load",&flag_schedule_speculative_load, 1 },
1113 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1 },
1114 {"sched-stalled-insns", &flag_sched_stalled_insns, 0 },
1115 {"sched-stalled-insns-dep", &flag_sched_stalled_insns_dep, 1 },
1116 {"sched2-use-superblocks", &flag_sched2_use_superblocks, 1 },
1117 {"sched2-use-traces", &flag_sched2_use_traces, 1 },
1118 {"branch-count-reg",&flag_branch_on_count_reg, 1 },
1119 {"pic", &flag_pic, 1 },
1120 {"PIC", &flag_pic, 2 },
1121 {"pie", &flag_pie, 1 },
1122 {"PIE", &flag_pie, 2 },
1123 {"exceptions", &flag_exceptions, 1 },
1124 {"unwind-tables", &flag_unwind_tables, 1 },
1125 {"asynchronous-unwind-tables", &flag_asynchronous_unwind_tables, 1 },
1126 {"non-call-exceptions", &flag_non_call_exceptions, 1 },
1127 {"profile-arcs", &profile_arc_flag, 1 },
1128 {"profile-values", &flag_profile_values, 1 },
1129 {"vpt", &flag_value_profile_transformations, 1 },
1130 {"test-coverage", &flag_test_coverage, 1 },
1131 {"branch-probabilities", &flag_branch_probabilities, 1 },
1132 {"profile", &profile_flag, 1 },
1133 {"reorder-blocks", &flag_reorder_blocks, 1 },
1134 {"reorder-functions", &flag_reorder_functions, 1 },
1135 {"rename-registers", &flag_rename_registers, 1 },
1136 {"cprop-registers", &flag_cprop_registers, 1 },
1137 {"common", &flag_no_common, 0 },
1138 {"inhibit-size-directive", &flag_inhibit_size_directive, 1 },
1139 {"function-sections", &flag_function_sections, 1 },
1140 {"data-sections", &flag_data_sections, 1 },
1141 {"verbose-asm", &flag_verbose_asm, 1 },
1142 {"regmove", &flag_regmove, 1 },
1143 {"optimize-register-move", &flag_regmove, 1 },
1144 {"pack-struct", &flag_pack_struct, 1 },
1145 {"stack-check", &flag_stack_check, 1 },
1146 {"argument-alias", &flag_argument_noalias, 0 },
1147 {"argument-noalias", &flag_argument_noalias, 1 },
1148 {"argument-noalias-global", &flag_argument_noalias, 2 },
1149 {"strict-aliasing", &flag_strict_aliasing, 1 },
1150 {"align-loops", &align_loops, 0 },
1151 {"align-jumps", &align_jumps, 0 },
1152 {"align-labels", &align_labels, 0 },
1153 {"align-functions", &align_functions, 0 },
1154 {"merge-constants", &flag_merge_constants, 1 },
1155 {"merge-all-constants", &flag_merge_constants, 2 },
1156 {"dump-unnumbered", &flag_dump_unnumbered, 1 },
1157 {"instrument-functions", &flag_instrument_function_entry_exit, 1 },
1158 {"zero-initialized-in-bss", &flag_zero_initialized_in_bss, 1 },
1159 {"leading-underscore", &flag_leading_underscore, 1 },
1160 {"ident", &flag_no_ident, 0 },
1161 { "peephole2", &flag_peephole2, 1 },
1162 {"finite-math-only", &flag_finite_math_only, 1 },
1163 { "guess-branch-probability", &flag_guess_branch_prob, 1 },
1164 {"math-errno", &flag_errno_math, 1 },
1165 {"trapping-math", &flag_trapping_math, 1 },
1166 {"rounding-math", &flag_rounding_math, 1 },
1167 {"unsafe-math-optimizations", &flag_unsafe_math_optimizations, 1 },
1168 {"signaling-nans", &flag_signaling_nans, 1 },
1169 {"bounds-check", &flag_bounds_check, 1 },
1170 {"single-precision-constant", &flag_single_precision_constant, 1 },
1171 {"time-report", &time_report, 1 },
1172 {"mem-report", &mem_report, 1 },
1173 { "trapv", &flag_trapv, 1 },
1174 { "wrapv", &flag_wrapv, 1 },
1175 { "new-ra", &flag_new_regalloc, 1 },
1176 { "var-tracking", &flag_var_tracking, 1}
1179 /* Here is a table, controlled by the tm.h file, listing each -m switch
1180 and which bits in `target_switches' it should set or clear.
1181 If VALUE is positive, it is bits to set.
1182 If VALUE is negative, -VALUE is bits to clear.
1183 (The sign bit is not used so there is no confusion.) */
1187 const char *const name;
1189 const char *const description;
1191 target_switches[] = TARGET_SWITCHES;
1193 /* This table is similar, but allows the switch to have a value. */
1195 #ifdef TARGET_OPTIONS
1198 const char *const prefix;
1199 const char **const variable;
1200 const char *const description;
1201 const char *const value;
1203 target_options[] = TARGET_OPTIONS;
1206 /* Nonzero means warn about function definitions that default the return type
1207 or that use a null return and have a return-type other than void. */
1209 int warn_return_type;
1211 /* Output files for assembler code (real compiler output)
1212 and debugging dumps. */
1215 FILE *aux_info_file;
1216 FILE *rtl_dump_file = NULL;
1217 FILE *cgraph_dump_file = NULL;
1219 /* The current working directory of a translation. It's generally the
1220 directory from which compilation was initiated, but a preprocessed
1221 file may specify the original directory in which it was
1224 static const char *src_pwd;
1226 /* Initialize src_pwd with the given string, and return true. If it
1227 was already initialized, return false. As a special case, it may
1228 be called with a NULL argument to test whether src_pwd has NOT been
1232 set_src_pwd (const char *pwd)
1237 src_pwd = xstrdup (pwd);
1241 /* Return the directory from which the translation unit was initiated,
1242 in case set_src_pwd() was not called before to assign it a
1249 src_pwd = getpwd ();
1254 /* Called when the start of a function definition is parsed,
1255 this function prints on stderr the name of the function. */
1257 announce_function (tree decl)
1261 if (rtl_dump_and_exit)
1262 verbatim ("%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
1264 verbatim (" %s", (*lang_hooks.decl_printable_name) (decl, 2));
1266 pp_needs_newline (global_dc->printer) = true;
1267 diagnostic_set_last_function (global_dc);
1271 /* Set up a default flag_random_seed and local_tick, unless the user
1272 already specified one. */
1277 if (!flag_random_seed)
1279 unsigned HOST_WIDE_INT value;
1280 static char random_seed[HOST_BITS_PER_WIDE_INT / 4 + 3];
1282 /* Get some more or less random data. */
1283 #ifdef HAVE_GETTIMEOFDAY
1287 gettimeofday (&tv, NULL);
1288 local_tick = tv.tv_sec * 1000 + tv.tv_usec / 1000;
1292 time_t now = time (NULL);
1294 if (now != (time_t)-1)
1295 local_tick = (unsigned) now;
1298 value = local_tick ^ getpid ();
1300 sprintf (random_seed, HOST_WIDE_INT_PRINT_HEX, value);
1301 flag_random_seed = random_seed;
1303 else if (!local_tick)
1308 /* Decode the string P as an integral parameter.
1309 If the string is indeed an integer return its numeric value else
1310 issue an Invalid Option error for the option PNAME and return DEFVAL.
1311 If PNAME is zero just return DEFVAL, do not call error. */
1314 read_integral_parameter (const char *p, const char *pname, const int defval)
1316 const char *endp = p;
1320 if (ISDIGIT (*endp))
1329 error ("invalid option argument `%s'", pname);
1336 /* Return the logarithm of X, base 2, considering X unsigned,
1337 if X is a power of 2. Otherwise, returns -1.
1339 This should be used via the `exact_log2' macro. */
1342 exact_log2_wide (unsigned HOST_WIDE_INT x)
1345 /* Test for 0 or a power of 2. */
1346 if (x == 0 || x != (x & -x))
1348 while ((x >>= 1) != 0)
1353 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
1354 If X is 0, return -1.
1356 This should be used via the floor_log2 macro. */
1359 floor_log2_wide (unsigned HOST_WIDE_INT x)
1368 /* Handler for fatal signals, such as SIGSEGV. These are transformed
1369 into ICE messages, which is much more user friendly. In case the
1370 error printer crashes, reset the signal to prevent infinite recursion. */
1373 crash_signal (int signo)
1375 signal (signo, SIG_DFL);
1376 internal_error ("%s", strsignal (signo));
1379 /* Arrange to dump core on error. (The regular error message is still
1380 printed first, except in the case of abort().) */
1383 setup_core_dumping (void)
1386 signal (SIGABRT, SIG_DFL);
1388 #if defined(HAVE_SETRLIMIT)
1391 if (getrlimit (RLIMIT_CORE, &rlim) != 0)
1392 fatal_error ("getting core file size maximum limit: %m");
1393 rlim.rlim_cur = rlim.rlim_max;
1394 if (setrlimit (RLIMIT_CORE, &rlim) != 0)
1395 fatal_error ("setting core file size limit to maximum: %m");
1398 diagnostic_abort_on_error (global_dc);
1402 /* Strip off a legitimate source ending from the input string NAME of
1403 length LEN. Rather than having to know the names used by all of
1404 our front ends, we strip off an ending of a period followed by
1405 up to five characters. (Java uses ".class".) */
1408 strip_off_ending (char *name, int len)
1411 for (i = 2; i < 6 && len > i; i++)
1413 if (name[len - i] == '.')
1415 name[len - i] = '\0';
1421 /* Output a quoted string. */
1424 output_quoted_string (FILE *asm_file, const char *string)
1426 #ifdef OUTPUT_QUOTED_STRING
1427 OUTPUT_QUOTED_STRING (asm_file, string);
1431 putc ('\"', asm_file);
1432 while ((c = *string++) != 0)
1436 if (c == '\"' || c == '\\')
1437 putc ('\\', asm_file);
1441 fprintf (asm_file, "\\%03o", (unsigned char) c);
1443 putc ('\"', asm_file);
1447 /* Output a file name in the form wanted by System V. */
1450 output_file_directive (FILE *asm_file, const char *input_name)
1455 if (input_name == NULL)
1456 input_name = "<stdin>";
1458 len = strlen (input_name);
1459 na = input_name + len;
1461 /* NA gets INPUT_NAME sans directory names. */
1462 while (na > input_name)
1464 if (IS_DIR_SEPARATOR (na[-1]))
1469 #ifdef ASM_OUTPUT_SOURCE_FILENAME
1470 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
1472 fprintf (asm_file, "\t.file\t");
1473 output_quoted_string (asm_file, na);
1474 fputc ('\n', asm_file);
1478 /* Routine to open a dump file. Return true if the dump file is enabled. */
1481 open_dump_file (enum dump_file_index index, tree decl)
1484 const char *open_arg;
1487 if (! dump_file[index].enabled)
1490 timevar_push (TV_DUMP);
1491 if (rtl_dump_file != NULL)
1492 fclose (rtl_dump_file);
1494 sprintf (seq, DUMPFILE_FORMAT, index);
1496 if (! dump_file[index].initialized)
1498 /* If we've not initialized the files, do so now. */
1499 if (graph_dump_format != no_graph
1500 && dump_file[index].graph_dump_p)
1502 dump_name = concat (seq, dump_file[index].extension, NULL);
1503 clean_graph_dump_file (dump_base_name, dump_name);
1506 dump_file[index].initialized = 1;
1512 dump_name = concat (dump_base_name, seq,
1513 dump_file[index].extension, NULL);
1515 rtl_dump_file = fopen (dump_name, open_arg);
1516 if (rtl_dump_file == NULL)
1517 fatal_error ("can't open %s: %m", dump_name);
1522 fprintf (rtl_dump_file, "\n;; Function %s%s\n\n",
1523 (*lang_hooks.decl_printable_name) (decl, 2),
1524 cfun->function_frequency == FUNCTION_FREQUENCY_HOT
1526 : cfun->function_frequency == FUNCTION_FREQUENCY_UNLIKELY_EXECUTED
1527 ? " (unlikely executed)"
1530 timevar_pop (TV_DUMP);
1534 /* Routine to close a dump file. */
1537 close_dump_file (enum dump_file_index index,
1538 void (*func) (FILE *, rtx),
1541 if (! rtl_dump_file)
1544 timevar_push (TV_DUMP);
1546 && graph_dump_format != no_graph
1547 && dump_file[index].graph_dump_p)
1552 sprintf (seq, DUMPFILE_FORMAT, index);
1553 suffix = concat (seq, dump_file[index].extension, NULL);
1554 print_rtl_graph_with_bb (dump_base_name, suffix, insns);
1559 func (rtl_dump_file, insns);
1561 fflush (rtl_dump_file);
1562 fclose (rtl_dump_file);
1564 rtl_dump_file = NULL;
1565 timevar_pop (TV_DUMP);
1568 /* Do any final processing required for the declarations in VEC, of
1569 which there are LEN. We write out inline functions and variables
1570 that have been deferred until this point, but which are required.
1571 Returns nonzero if anything was put out. */
1574 wrapup_global_declarations (tree *vec, int len)
1579 int output_something = 0;
1581 for (i = 0; i < len; i++)
1585 /* We're not deferring this any longer. Assignment is
1586 conditional to avoid needlessly dirtying PCH pages. */
1587 if (DECL_DEFER_OUTPUT (decl) != 0)
1588 DECL_DEFER_OUTPUT (decl) = 0;
1590 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0)
1591 (*lang_hooks.finish_incomplete_decl) (decl);
1594 /* Now emit any global variables or functions that we have been
1595 putting off. We need to loop in case one of the things emitted
1596 here references another one which comes earlier in the list. */
1600 for (i = 0; i < len; i++)
1604 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
1607 /* Don't write out static consts, unless we still need them.
1609 We also keep static consts if not optimizing (for debugging),
1610 unless the user specified -fno-keep-static-consts.
1611 ??? They might be better written into the debug information.
1612 This is possible when using DWARF.
1614 A language processor that wants static constants to be always
1615 written out (even if it is not used) is responsible for
1616 calling rest_of_decl_compilation itself. E.g. the C front-end
1617 calls rest_of_decl_compilation from finish_decl.
1618 One motivation for this is that is conventional in some
1619 environments to write things like:
1620 static const char rcsid[] = "... version string ...";
1621 intending to force the string to be in the executable.
1623 A language processor that would prefer to have unneeded
1624 static constants "optimized away" would just defer writing
1625 them out until here. E.g. C++ does this, because static
1626 constants are often defined in header files.
1628 ??? A tempting alternative (for both C and C++) would be
1629 to force a constant to be written if and only if it is
1630 defined in a main file, as opposed to an include file. */
1632 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl))
1636 if (flag_unit_at_a_time
1637 && cgraph_varpool_node (decl)->finalized)
1639 else if ((flag_unit_at_a_time && !cgraph_global_info_ready)
1640 && (TREE_USED (decl)
1641 || TREE_USED (DECL_ASSEMBLER_NAME (decl))))
1643 else if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
1645 else if (DECL_COMDAT (decl))
1647 else if (TREE_READONLY (decl) && !TREE_PUBLIC (decl)
1648 && (optimize || !flag_keep_static_consts
1649 || DECL_ARTIFICIAL (decl)))
1655 rest_of_decl_compilation (decl, NULL, 1, 1);
1659 if (TREE_CODE (decl) == FUNCTION_DECL
1660 && DECL_INITIAL (decl) != 0
1661 && DECL_STRUCT_FUNCTION (decl) != 0
1662 && DECL_STRUCT_FUNCTION (decl)->saved_for_inline
1663 && (flag_keep_inline_functions
1664 || (TREE_PUBLIC (decl) && !DECL_COMDAT (decl))
1665 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
1668 output_inline_function (decl);
1673 output_something = 1;
1677 return output_something;
1680 /* Issue appropriate warnings for the global declarations in VEC (of
1681 which there are LEN). Output debugging information for them. */
1684 check_global_declarations (tree *vec, int len)
1689 for (i = 0; i < len; i++)
1693 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
1694 && ! TREE_ASM_WRITTEN (decl))
1695 /* Cancel the RTL for this decl so that, if debugging info
1696 output for global variables is still to come,
1697 this one will be omitted. */
1698 SET_DECL_RTL (decl, NULL_RTX);
1700 /* Warn about any function
1701 declared static but not defined.
1702 We don't warn about variables,
1703 because many programs have static variables
1704 that exist only to get some text into the object file. */
1705 if (TREE_CODE (decl) == FUNCTION_DECL
1706 && (warn_unused_function
1707 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
1708 && DECL_INITIAL (decl) == 0
1709 && DECL_EXTERNAL (decl)
1710 && ! DECL_ARTIFICIAL (decl)
1711 && ! TREE_PUBLIC (decl))
1713 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
1714 pedwarn ("%J'%F' used but never defined", decl, decl);
1716 warning ("%J'%F' declared `static' but never defined", decl, decl);
1717 /* This symbol is effectively an "extern" declaration now. */
1718 TREE_PUBLIC (decl) = 1;
1719 assemble_external (decl);
1722 /* Warn about static fns or vars defined but not used. */
1723 if (((warn_unused_function && TREE_CODE (decl) == FUNCTION_DECL)
1724 /* We don't warn about "static const" variables because the
1725 "rcs_id" idiom uses that construction. */
1726 || (warn_unused_variable
1727 && TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
1728 && ! DECL_IN_SYSTEM_HEADER (decl)
1729 && ! TREE_USED (decl)
1730 /* The TREE_USED bit for file-scope decls is kept in the identifier,
1731 to handle multiple external decls in different scopes. */
1732 && ! TREE_USED (DECL_NAME (decl))
1733 && ! DECL_EXTERNAL (decl)
1734 && ! TREE_PUBLIC (decl)
1735 /* A volatile variable might be used in some non-obvious way. */
1736 && ! TREE_THIS_VOLATILE (decl)
1737 /* Global register variables must be declared to reserve them. */
1738 && ! (TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl))
1739 /* Otherwise, ask the language. */
1740 && (*lang_hooks.decls.warn_unused_global) (decl))
1741 warning ("%J'%D' defined but not used", decl, decl);
1743 /* Avoid confusing the debug information machinery when there are
1745 if (errorcount == 0 && sorrycount == 0)
1747 timevar_push (TV_SYMOUT);
1748 (*debug_hooks->global_decl) (decl);
1749 timevar_pop (TV_SYMOUT);
1754 /* Warn about a use of an identifier which was marked deprecated. */
1756 warn_deprecated_use (tree node)
1758 if (node == 0 || !warn_deprecated_decl)
1762 warning ("`%s' is deprecated (declared at %s:%d)",
1763 IDENTIFIER_POINTER (DECL_NAME (node)),
1764 DECL_SOURCE_FILE (node), DECL_SOURCE_LINE (node));
1765 else if (TYPE_P (node))
1767 const char *what = NULL;
1768 tree decl = TYPE_STUB_DECL (node);
1770 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
1771 what = IDENTIFIER_POINTER (TYPE_NAME (node));
1772 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
1773 && DECL_NAME (TYPE_NAME (node)))
1774 what = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node)));
1779 warning ("`%s' is deprecated (declared at %s:%d)", what,
1780 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1782 warning ("`%s' is deprecated", what);
1785 warning ("type is deprecated (declared at %s:%d)",
1786 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
1788 warning ("type is deprecated");
1792 /* Save the current INPUT_LOCATION on the top entry in the
1793 INPUT_FILE_STACK. Push a new entry for FILE and LINE, and set the
1794 INPUT_LOCATION accordingly. */
1797 push_srcloc (const char *file, int line)
1799 struct file_stack *fs;
1801 fs = xmalloc (sizeof (struct file_stack));
1802 fs->location = input_location;
1803 fs->next = input_file_stack;
1804 input_filename = file;
1806 input_file_stack = fs;
1807 input_file_stack_tick++;
1810 /* Pop the top entry off the stack of presently open source files.
1811 Restore the INPUT_LOCATION from the new topmost entry on the
1817 struct file_stack *fs;
1819 fs = input_file_stack;
1820 input_location = fs->location;
1821 input_file_stack = fs->next;
1823 input_file_stack_tick++;
1826 /* Compile an entire translation unit. Write a file of assembly
1827 output and various debugging dumps. */
1832 /* Initialize yet another pass. */
1834 init_final (main_input_filename);
1835 coverage_init (aux_base_name);
1837 timevar_push (TV_PARSE);
1839 /* Call the parser, which parses the entire file (calling
1840 rest_of_compilation for each function). */
1841 (*lang_hooks.parse_file) (set_yydebug);
1843 /* In case there were missing block closers,
1844 get us back to the global binding level. */
1845 (*lang_hooks.clear_binding_stack) ();
1847 /* Compilation is now finished except for writing
1848 what's left of the symbol table output. */
1849 timevar_pop (TV_PARSE);
1851 if (flag_syntax_only)
1854 (*lang_hooks.decls.final_write_globals)();
1856 cgraph_varpool_assemble_pending_decls ();
1858 /* This must occur after the loop to output deferred functions.
1859 Else the coverage initializer would not be emitted if all the
1860 functions in this compilation unit were deferred. */
1863 /* Write out any pending weak symbol declarations. */
1867 /* Do dbx symbols. */
1868 timevar_push (TV_SYMOUT);
1870 #ifdef DWARF2_UNWIND_INFO
1871 if (dwarf2out_do_frame ())
1872 dwarf2out_frame_finish ();
1875 (*debug_hooks->finish) (main_input_filename);
1876 timevar_pop (TV_SYMOUT);
1878 /* Output some stuff at end of file if nec. */
1880 dw2_output_indirect_constants ();
1882 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
1884 timevar_push (TV_DUMP);
1885 open_dump_file (DFI_bp, NULL);
1889 close_dump_file (DFI_bp, NULL, NULL_RTX);
1890 timevar_pop (TV_DUMP);
1893 targetm.asm_out.file_end ();
1895 /* Attach a special .ident directive to the end of the file to identify
1896 the version of GCC which compiled this code. The format of the .ident
1897 string is patterned after the ones produced by native SVR4 compilers. */
1900 fprintf (asm_out_file, "%s\"GCC: (GNU) %s\"\n",
1901 IDENT_ASM_OP, version_string);
1904 if (optimize > 0 && open_dump_file (DFI_combine, NULL))
1906 timevar_push (TV_DUMP);
1907 dump_combine_total_stats (rtl_dump_file);
1908 close_dump_file (DFI_combine, NULL, NULL_RTX);
1909 timevar_pop (TV_DUMP);
1913 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
1914 and TYPE_DECL nodes.
1916 This does nothing for local (non-static) variables, unless the
1917 variable is a register variable with an ASMSPEC. In that case, or
1918 if the variable is not an automatic, it sets up the RTL and
1919 outputs any assembler code (label definition, storage allocation
1920 and initialization).
1922 DECL is the declaration. If ASMSPEC is nonzero, it specifies
1923 the assembler symbol name to be used. TOP_LEVEL is nonzero
1924 if this declaration is not within a function. */
1927 rest_of_decl_compilation (tree decl,
1928 const char *asmspec,
1932 /* We deferred calling assemble_alias so that we could collect
1933 other attributes such as visibility. Emit the alias now. */
1936 alias = lookup_attribute ("alias", DECL_ATTRIBUTES (decl));
1939 alias = TREE_VALUE (TREE_VALUE (alias));
1940 alias = get_identifier (TREE_STRING_POINTER (alias));
1941 assemble_alias (decl, alias);
1945 /* Forward declarations for nested functions are not "external",
1946 but we need to treat them as if they were. */
1947 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
1948 || TREE_CODE (decl) == FUNCTION_DECL)
1950 timevar_push (TV_VARCONST);
1953 make_decl_rtl (decl, asmspec);
1955 /* Don't output anything when a tentative file-scope definition
1956 is seen. But at end of compilation, do output code for them.
1958 We do output all variables when unit-at-a-time is active and rely on
1959 callgraph code to defer them except for forward declarations
1960 (see gcc.c-torture/compile/920624-1.c) */
1962 || !DECL_DEFER_OUTPUT (decl)
1963 || (flag_unit_at_a_time && DECL_INITIAL (decl)))
1964 && !DECL_EXTERNAL (decl))
1966 if (flag_unit_at_a_time && !cgraph_global_info_ready
1967 && TREE_CODE (decl) != FUNCTION_DECL && top_level)
1968 cgraph_varpool_finalize_decl (decl);
1970 assemble_variable (decl, top_level, at_end, 0);
1973 #ifdef ASM_FINISH_DECLARE_OBJECT
1974 if (decl == last_assemble_variable_decl)
1976 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
1981 timevar_pop (TV_VARCONST);
1983 else if (DECL_REGISTER (decl) && asmspec != 0)
1985 if (decode_reg_name (asmspec) >= 0)
1987 SET_DECL_RTL (decl, NULL_RTX);
1988 make_decl_rtl (decl, asmspec);
1992 error ("invalid register name `%s' for register variable", asmspec);
1993 DECL_REGISTER (decl) = 0;
1998 else if (TREE_CODE (decl) == TYPE_DECL)
2000 timevar_push (TV_SYMOUT);
2001 debug_hooks->type_decl (decl, !top_level);
2002 timevar_pop (TV_SYMOUT);
2006 /* Called after finishing a record, union or enumeral type. */
2009 rest_of_type_compilation (tree type, int toplev)
2011 /* Avoid confusing the debug information machinery when there are
2013 if (errorcount != 0 || sorrycount != 0)
2016 timevar_push (TV_SYMOUT);
2017 debug_hooks->type_decl (TYPE_STUB_DECL (type), !toplev);
2018 timevar_pop (TV_SYMOUT);
2021 /* Turn the RTL into assembly. */
2023 rest_of_handle_final (tree decl, rtx insns)
2025 timevar_push (TV_FINAL);
2030 /* Get the function's name, as described by its RTL. This may be
2031 different from the DECL_NAME name used in the source file. */
2033 x = DECL_RTL (decl);
2034 if (GET_CODE (x) != MEM)
2037 if (GET_CODE (x) != SYMBOL_REF)
2039 fnname = XSTR (x, 0);
2041 assemble_start_function (decl, fnname);
2042 final_start_function (insns, asm_out_file, optimize);
2043 final (insns, asm_out_file, optimize, 0);
2044 final_end_function ();
2046 #ifdef IA64_UNWIND_INFO
2047 /* ??? The IA-64 ".handlerdata" directive must be issued before
2048 the ".endp" directive that closes the procedure descriptor. */
2049 output_function_exception_table ();
2052 assemble_end_function (decl, fnname);
2054 #ifndef IA64_UNWIND_INFO
2055 /* Otherwise, it feels unclean to switch sections in the middle. */
2056 output_function_exception_table ();
2060 fflush (asm_out_file);
2062 /* Release all memory allocated by flow. */
2063 free_basic_block_vars (0);
2065 /* Release all memory held by regsets now. */
2066 regset_release_memory ();
2068 timevar_pop (TV_FINAL);
2074 /* Run delay slot optimization. */
2076 rest_of_handle_delay_slots (tree decl, rtx insns)
2078 timevar_push (TV_DBR_SCHED);
2079 open_dump_file (DFI_dbr, decl);
2081 dbr_schedule (insns, rtl_dump_file);
2083 close_dump_file (DFI_dbr, print_rtl, insns);
2084 timevar_pop (TV_DBR_SCHED);
2091 /* Convert register usage from flat register file usage to a stack
2094 rest_of_handle_stack_regs (tree decl, rtx insns)
2096 #if defined (HAVE_ATTR_length)
2097 /* If flow2 creates new instructions which need splitting
2098 and scheduling after reload is not done, they might not be
2099 split until final which doesn't allow splitting
2100 if HAVE_ATTR_length. */
2101 #ifdef INSN_SCHEDULING
2102 if (optimize && !flag_schedule_insns_after_reload)
2107 timevar_push (TV_SHORTEN_BRANCH);
2108 split_all_insns (1);
2109 timevar_pop (TV_SHORTEN_BRANCH);
2113 timevar_push (TV_REG_STACK);
2114 open_dump_file (DFI_stack, decl);
2116 if (reg_to_stack (insns, rtl_dump_file) && optimize)
2118 if (cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK
2119 | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0))
2120 && flag_reorder_blocks)
2122 reorder_basic_blocks ();
2123 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK);
2127 close_dump_file (DFI_stack, print_rtl_with_bb, insns);
2128 timevar_pop (TV_REG_STACK);
2134 /* Track the variables, ie. compute where the variable is stored at each position in function. */
2136 rest_of_handle_variable_tracking (tree decl, rtx insns)
2138 timevar_push (TV_VAR_TRACKING);
2139 open_dump_file (DFI_vartrack, decl);
2141 variable_tracking_main ();
2143 close_dump_file (DFI_vartrack, print_rtl_with_bb, insns);
2144 timevar_pop (TV_VAR_TRACKING);
2147 /* Machine independent reorg pass. */
2149 rest_of_handle_machine_reorg (tree decl, rtx insns)
2151 timevar_push (TV_MACH_DEP);
2152 open_dump_file (DFI_mach, decl);
2154 (*targetm.machine_dependent_reorg) ();
2156 close_dump_file (DFI_mach, print_rtl, insns);
2157 timevar_pop (TV_MACH_DEP);
2163 /* Run new register allocator. Return TRUE if we must exit
2164 rest_of_compilation upon return. */
2166 rest_of_handle_new_regalloc (tree decl, rtx insns)
2170 delete_trivially_dead_insns (insns, max_reg_num ());
2173 timevar_pop (TV_LOCAL_ALLOC);
2174 if (dump_file[DFI_lreg].enabled)
2176 timevar_push (TV_DUMP);
2178 close_dump_file (DFI_lreg, NULL, NULL);
2179 timevar_pop (TV_DUMP);
2182 /* XXX clean up the whole mess to bring live info in shape again. */
2183 timevar_push (TV_GLOBAL_ALLOC);
2184 open_dump_file (DFI_greg, decl);
2186 build_insn_chain (insns);
2187 failure = reload (insns, 0);
2189 timevar_pop (TV_GLOBAL_ALLOC);
2191 if (dump_file[DFI_greg].enabled)
2193 timevar_push (TV_DUMP);
2195 dump_global_regs (rtl_dump_file);
2197 close_dump_file (DFI_greg, print_rtl_with_bb, insns);
2198 timevar_pop (TV_DUMP);
2204 reload_completed = 1;
2209 /* Run old register allocator. Return TRUE if we must exit
2210 rest_of_compilation upon return. */
2212 rest_of_handle_old_regalloc (tree decl, rtx insns)
2217 /* Allocate the reg_renumber array. */
2218 allocate_reg_info (max_regno, FALSE, TRUE);
2220 /* And the reg_equiv_memory_loc array. */
2221 reg_equiv_memory_loc = xcalloc (max_regno, sizeof (rtx));
2223 allocate_initial_values (reg_equiv_memory_loc);
2225 regclass (insns, max_reg_num (), rtl_dump_file);
2226 rebuild_notes = local_alloc ();
2228 timevar_pop (TV_LOCAL_ALLOC);
2230 /* Local allocation may have turned an indirect jump into a direct
2231 jump. If so, we must rebuild the JUMP_LABEL fields of jumping
2235 timevar_push (TV_JUMP);
2237 rebuild_jump_labels (insns);
2238 purge_all_dead_edges (0);
2240 timevar_pop (TV_JUMP);
2243 if (dump_file[DFI_lreg].enabled)
2245 timevar_push (TV_DUMP);
2247 dump_flow_info (rtl_dump_file);
2248 dump_local_alloc (rtl_dump_file);
2250 close_dump_file (DFI_lreg, print_rtl_with_bb, insns);
2251 timevar_pop (TV_DUMP);
2256 timevar_push (TV_GLOBAL_ALLOC);
2257 open_dump_file (DFI_greg, decl);
2259 /* If optimizing, allocate remaining pseudo-regs. Do the reload
2260 pass fixing up any insns that are invalid. */
2263 failure = global_alloc (rtl_dump_file);
2266 build_insn_chain (insns);
2267 failure = reload (insns, 0);
2270 timevar_pop (TV_GLOBAL_ALLOC);
2272 if (dump_file[DFI_greg].enabled)
2274 timevar_push (TV_DUMP);
2276 dump_global_regs (rtl_dump_file);
2278 close_dump_file (DFI_greg, print_rtl_with_bb, insns);
2279 timevar_pop (TV_DUMP);
2285 /* Run the regrename and cprop passes. */
2287 rest_of_handle_regrename (tree decl, rtx insns)
2289 timevar_push (TV_RENAME_REGISTERS);
2290 open_dump_file (DFI_rnreg, decl);
2292 if (flag_rename_registers)
2293 regrename_optimize ();
2294 if (flag_cprop_registers)
2295 copyprop_hardreg_forward ();
2297 close_dump_file (DFI_rnreg, print_rtl_with_bb, insns);
2298 timevar_pop (TV_RENAME_REGISTERS);
2301 /* Reorder basic blocks. */
2303 rest_of_handle_reorder_blocks (tree decl, rtx insns)
2306 open_dump_file (DFI_bbro, decl);
2308 /* Last attempt to optimize CFG, as scheduling, peepholing and insn
2309 splitting possibly introduced more crossjumping opportunities. */
2310 changed = cleanup_cfg (CLEANUP_EXPENSIVE
2311 | (!HAVE_conditional_execution
2312 ? CLEANUP_UPDATE_LIFE : 0));
2314 if (flag_sched2_use_traces && flag_schedule_insns_after_reload)
2316 if (flag_reorder_blocks)
2317 reorder_basic_blocks ();
2318 if (flag_reorder_blocks
2319 || (flag_sched2_use_traces && flag_schedule_insns_after_reload))
2320 changed |= cleanup_cfg (CLEANUP_EXPENSIVE
2321 | (!HAVE_conditional_execution
2322 ? CLEANUP_UPDATE_LIFE : 0));
2324 /* On conditional execution targets we can not update the life cheaply, so
2325 we deffer the updating to after both cleanups. This may lose some cases
2326 but should not be terribly bad. */
2327 if (changed && HAVE_conditional_execution)
2328 update_life_info (NULL, UPDATE_LIFE_GLOBAL_RM_NOTES,
2330 close_dump_file (DFI_bbro, print_rtl_with_bb, insns);
2333 #ifdef INSN_SCHEDULING
2334 /* Run instruction scheduler. */
2336 rest_of_handle_sched (tree decl, rtx insns)
2338 timevar_push (TV_SCHED);
2340 /* Print function header into sched dump now
2341 because doing the sched analysis makes some of the dump. */
2342 if (optimize > 0 && flag_schedule_insns)
2344 open_dump_file (DFI_sched, decl);
2346 /* Do control and data sched analysis,
2347 and write some of the results to dump file. */
2349 schedule_insns (rtl_dump_file);
2351 close_dump_file (DFI_sched, print_rtl_with_bb, insns);
2353 timevar_pop (TV_SCHED);
2358 /* Run second scheduling pass after reload. */
2360 rest_of_handle_sched2 (tree decl, rtx insns)
2362 timevar_push (TV_SCHED2);
2363 open_dump_file (DFI_sched2, decl);
2365 /* Do control and data sched analysis again,
2366 and write some more of the results to dump file. */
2368 split_all_insns (1);
2370 if (flag_sched2_use_superblocks || flag_sched2_use_traces)
2372 schedule_ebbs (rtl_dump_file);
2373 /* No liveness updating code yet, but it should be easy to do.
2374 reg-stack recompute the liveness when needed for now. */
2375 count_or_remove_death_notes (NULL, 1);
2376 cleanup_cfg (CLEANUP_EXPENSIVE);
2379 schedule_insns (rtl_dump_file);
2381 close_dump_file (DFI_sched2, print_rtl_with_bb, insns);
2382 timevar_pop (TV_SCHED2);
2388 /* Register allocation pre-pass, to reduce number of moves necessary
2389 for two-address machines. */
2391 rest_of_handle_regmove (tree decl, rtx insns)
2393 timevar_push (TV_REGMOVE);
2394 open_dump_file (DFI_regmove, decl);
2396 regmove_optimize (insns, max_reg_num (), rtl_dump_file);
2398 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
2399 close_dump_file (DFI_regmove, print_rtl_with_bb, insns);
2400 timevar_pop (TV_REGMOVE);
2407 rest_of_handle_tracer (tree decl, rtx insns)
2409 open_dump_file (DFI_tracer, decl);
2411 dump_flow_info (rtl_dump_file);
2413 cleanup_cfg (CLEANUP_EXPENSIVE);
2414 reg_scan (insns, max_reg_num (), 0);
2415 close_dump_file (DFI_tracer, print_rtl_with_bb, get_insns ());
2418 /* If-conversion and CFG cleanup. */
2420 rest_of_handle_if_conversion (tree decl, rtx insns)
2422 open_dump_file (DFI_ce1, decl);
2423 if (flag_if_conversion)
2425 timevar_push (TV_IFCVT);
2427 dump_flow_info (rtl_dump_file);
2428 cleanup_cfg (CLEANUP_EXPENSIVE);
2429 reg_scan (insns, max_reg_num (), 0);
2431 timevar_pop (TV_IFCVT);
2433 timevar_push (TV_JUMP);
2434 cleanup_cfg (CLEANUP_EXPENSIVE);
2435 reg_scan (insns, max_reg_num (), 0);
2436 timevar_pop (TV_JUMP);
2437 close_dump_file (DFI_ce1, print_rtl_with_bb, get_insns ());
2440 /* Rerun if-conversion, as combine may have simplified things enough
2441 to now meet sequence length restrictions. */
2443 rest_of_handle_if_after_combine (tree decl, rtx insns)
2445 timevar_push (TV_IFCVT);
2446 open_dump_file (DFI_ce2, decl);
2452 close_dump_file (DFI_ce2, print_rtl_with_bb, insns);
2453 timevar_pop (TV_IFCVT);
2457 rest_of_handle_web (tree decl, rtx insns)
2459 open_dump_file (DFI_web, decl);
2460 timevar_push (TV_WEB);
2462 delete_trivially_dead_insns (insns, max_reg_num ());
2463 cleanup_cfg (CLEANUP_EXPENSIVE);
2465 timevar_pop (TV_WEB);
2466 close_dump_file (DFI_web, print_rtl_with_bb, insns);
2467 reg_scan (get_insns (), max_reg_num (), 0);
2470 /* Do branch profiling and static profile estimation passes. */
2472 rest_of_handle_branch_prob (tree decl, rtx insns)
2476 timevar_push (TV_BRANCH_PROB);
2477 open_dump_file (DFI_bp, decl);
2479 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
2482 /* Discover and record the loop depth at the head of each basic
2483 block. The loop infrastructure does the real job for us. */
2484 flow_loops_find (&loops, LOOP_TREE);
2487 flow_loops_dump (&loops, rtl_dump_file, NULL, 0);
2489 /* Estimate using heuristics if no profiling info is available. */
2490 if (flag_guess_branch_prob)
2491 estimate_probability (&loops);
2493 flow_loops_free (&loops);
2494 free_dominance_info (CDI_DOMINATORS);
2495 close_dump_file (DFI_bp, print_rtl_with_bb, insns);
2496 timevar_pop (TV_BRANCH_PROB);
2499 /* Do optimizations based on expression value profiles. */
2501 rest_of_handle_value_profile_transformations (tree decl, rtx insns)
2503 open_dump_file (DFI_vpt, decl);
2504 timevar_push (TV_VPT);
2506 if (value_profile_transformations ())
2507 cleanup_cfg (CLEANUP_EXPENSIVE);
2509 timevar_pop (TV_VPT);
2510 close_dump_file (DFI_vpt, print_rtl_with_bb, insns);
2513 /* Do control and data flow analysis; write some of the results to the
2516 rest_of_handle_cfg (tree decl, rtx insns)
2518 open_dump_file (DFI_cfg, decl);
2520 dump_flow_info (rtl_dump_file);
2522 cleanup_cfg (CLEANUP_EXPENSIVE
2523 | (flag_thread_jumps ? CLEANUP_THREADING : 0));
2525 /* It may make more sense to mark constant functions after dead code is
2526 eliminated by life_analysis, but we need to do it early, as -fprofile-arcs
2527 may insert code making function non-constant, but we still must consider
2528 it as constant, otherwise -fbranch-probabilities will not read data back.
2530 life_analysis rarely eliminates modification of external memory.
2534 /* Alias analysis depends on this information and mark_constant_function
2535 depends on alias analysis. */
2536 reg_scan (insns, max_reg_num (), 1);
2537 mark_constant_function ();
2540 close_dump_file (DFI_cfg, print_rtl_with_bb, insns);
2543 /* Purge addressofs. */
2545 rest_of_handle_addressof (tree decl, rtx insns)
2547 open_dump_file (DFI_addressof, decl);
2549 purge_addressof (insns);
2550 if (optimize && purge_all_dead_edges (0))
2551 delete_unreachable_blocks ();
2552 reg_scan (insns, max_reg_num (), 1);
2554 close_dump_file (DFI_addressof, print_rtl, insns);
2557 /* We may have potential sibling or tail recursion sites. Select one
2558 (of possibly multiple) methods of performing the call. */
2560 rest_of_handle_sibling_calls (rtx insns)
2563 optimize_sibling_and_tail_recursive_calls ();
2565 /* Recompute the CFG as sibling optimization clobbers it randomly. */
2566 free_bb_for_insn ();
2567 find_exception_handler_labels ();
2568 rebuild_jump_labels (insns);
2569 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2571 /* There is pass ordering problem - we must lower NOTE_INSN_PREDICTION
2572 notes before simplifying cfg and we must do lowering after sibcall
2573 that unhides parts of RTL chain and cleans up the CFG.
2575 Until sibcall is replaced by tree-level optimizer, lets just
2576 sweep away the NOTE_INSN_PREDICTION notes that leaked out. */
2577 for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
2578 if (GET_CODE (insn) == NOTE
2579 && NOTE_LINE_NUMBER (insn) == NOTE_INSN_PREDICTION)
2582 close_dump_file (DFI_sibling, print_rtl, get_insns ());
2585 /* Perform jump bypassing and control flow optimizations. */
2587 rest_of_handle_jump_bypass (tree decl, rtx insns)
2589 timevar_push (TV_BYPASS);
2590 open_dump_file (DFI_bypass, decl);
2592 cleanup_cfg (CLEANUP_EXPENSIVE);
2593 reg_scan (insns, max_reg_num (), 1);
2595 if (bypass_jumps (rtl_dump_file))
2597 rebuild_jump_labels (insns);
2598 cleanup_cfg (CLEANUP_EXPENSIVE);
2599 delete_trivially_dead_insns (insns, max_reg_num ());
2602 close_dump_file (DFI_bypass, print_rtl_with_bb, insns);
2603 timevar_pop (TV_BYPASS);
2607 #ifdef ENABLE_CHECKING
2608 verify_flow_info ();
2612 /* Handle inlining of functions in rest_of_compilation. Return TRUE
2613 if we must exit rest_of_compilation upon return. */
2615 rest_of_handle_inlining (tree decl)
2622 /* If we are reconsidering an inline function at the end of
2623 compilation, skip the stuff for making it inline. */
2624 if (cfun->rtl_inline_init)
2626 cfun->rtl_inline_init = 1;
2628 /* If this is nested inside an inlined external function, pretend
2629 it was only declared. Since we cannot inline such functions,
2630 generating code for this one is not only not necessary but will
2631 confuse some debugging output writers. */
2632 for (parent = DECL_CONTEXT (current_function_decl);
2633 parent != NULL_TREE;
2634 parent = get_containing_scope (parent))
2635 if (TREE_CODE (parent) == FUNCTION_DECL
2636 && DECL_INLINE (parent) && DECL_EXTERNAL (parent))
2638 DECL_INITIAL (decl) = 0;
2641 else if (TYPE_P (parent))
2642 /* A function in a local class should be treated normally. */
2645 /* If requested, consider whether to make this function inline. */
2646 if ((DECL_INLINE (decl) && !flag_no_inline)
2647 || flag_inline_functions)
2649 timevar_push (TV_INTEGRATION);
2650 lose = function_cannot_inline_p (decl);
2651 timevar_pop (TV_INTEGRATION);
2652 if (lose || ! optimize)
2654 if (warn_inline && lose && DECL_INLINE (decl))
2656 char *msg = concat ("%J", lose, NULL);
2657 warning (msg, decl);
2660 DECL_ABSTRACT_ORIGIN (decl) = 0;
2661 /* Don't really compile an extern inline function.
2662 If we can't make it inline, pretend
2663 it was only declared. */
2664 if (DECL_EXTERNAL (decl))
2666 DECL_INITIAL (decl) = 0;
2671 inlinable = DECL_INLINE (decl) = 1;
2674 insns = get_insns ();
2676 /* Dump the rtl code if we are dumping rtl. */
2678 if (open_dump_file (DFI_rtl, decl))
2680 if (DECL_STRUCT_FUNCTION (decl)
2681 && DECL_STRUCT_FUNCTION (decl)->saved_for_inline)
2682 fprintf (rtl_dump_file, ";; (integrable)\n\n");
2683 close_dump_file (DFI_rtl, print_rtl, insns);
2686 /* Convert from NOTE_INSN_EH_REGION style notes, and do other
2687 sorts of eh initialization. Delay this until after the
2688 initial rtl dump so that we can see the original nesting. */
2689 convert_from_eh_region_ranges ();
2691 /* If function is inline, and we don't yet know whether to
2692 compile it by itself, defer decision till end of compilation.
2693 wrapup_global_declarations will (indirectly) call
2694 rest_of_compilation again for those functions that need to
2695 be output. Also defer those functions that we are supposed
2699 || (DECL_INLINE (decl)
2700 /* Egad. This RTL deferral test conflicts with Fortran assumptions
2701 for unreferenced symbols. See g77.f-torture/execute/980520-1.f.
2702 But removing this line from the check breaks all languages that
2703 use the call graph to output symbols. This hard-coded check is
2704 the least invasive work-around. */
2705 && (flag_inline_functions
2706 || strcmp (lang_hooks.name, "GNU F77") == 0)
2707 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
2708 && ! TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))
2709 && ! flag_keep_inline_functions)
2710 || DECL_EXTERNAL (decl))))
2711 DECL_DEFER_OUTPUT (decl) = 1;
2713 if (DECL_INLINE (decl))
2714 /* DWARF wants separate debugging info for abstract and
2715 concrete instances of all inline functions, including those
2716 declared inline but not inlined, and those inlined even
2717 though they weren't declared inline. Conveniently, that's
2718 what DECL_INLINE means at this point. */
2719 (*debug_hooks->deferred_inline_function) (decl);
2721 if (DECL_DEFER_OUTPUT (decl))
2723 /* If -Wreturn-type, we have to do a bit of compilation. We just
2724 want to call cleanup the cfg to figure out whether or not we can
2725 fall off the end of the function; we do the minimum amount of
2726 work necessary to make that safe. */
2727 if (warn_return_type)
2729 int saved_optimize = optimize;
2732 rebuild_jump_labels (insns);
2733 find_exception_handler_labels ();
2734 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
2735 cleanup_cfg (CLEANUP_PRE_SIBCALL | CLEANUP_PRE_LOOP);
2736 optimize = saved_optimize;
2738 /* CFG is no longer maintained up-to-date. */
2739 free_bb_for_insn ();
2742 set_nothrow_function_flags ();
2743 if (current_function_nothrow)
2744 /* Now we know that this can't throw; set the flag for the benefit
2745 of other functions later in this translation unit. */
2746 TREE_NOTHROW (current_function_decl) = 1;
2748 timevar_push (TV_INTEGRATION);
2749 save_for_inline (decl);
2750 timevar_pop (TV_INTEGRATION);
2751 DECL_STRUCT_FUNCTION (decl)->inlinable = inlinable;
2755 /* If specified extern inline but we aren't inlining it, we are
2756 done. This goes for anything that gets here with DECL_EXTERNAL
2757 set, not just things with DECL_INLINE. */
2758 return (bool) DECL_EXTERNAL (decl);
2761 /* Try to identify useless null pointer tests and delete them. */
2763 rest_of_handle_null_pointer (tree decl, rtx insns)
2765 open_dump_file (DFI_null, decl);
2767 dump_flow_info (rtl_dump_file);
2769 if (delete_null_pointer_checks (insns))
2770 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2772 close_dump_file (DFI_null, print_rtl_with_bb, insns);
2775 /* Try combining insns through substitution. */
2777 rest_of_handle_combine (tree decl, rtx insns)
2779 int rebuild_jump_labels_after_combine = 0;
2781 timevar_push (TV_COMBINE);
2782 open_dump_file (DFI_combine, decl);
2784 rebuild_jump_labels_after_combine
2785 = combine_instructions (insns, max_reg_num ());
2787 /* Combining insns may have turned an indirect jump into a
2788 direct jump. Rebuild the JUMP_LABEL fields of jumping
2790 if (rebuild_jump_labels_after_combine)
2792 timevar_push (TV_JUMP);
2793 rebuild_jump_labels (insns);
2794 timevar_pop (TV_JUMP);
2796 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
2799 close_dump_file (DFI_combine, print_rtl_with_bb, insns);
2800 timevar_pop (TV_COMBINE);
2805 /* Perform life analysis. */
2807 rest_of_handle_life (tree decl, rtx insns)
2809 open_dump_file (DFI_life, decl);
2812 #ifdef ENABLE_CHECKING
2813 verify_flow_info ();
2815 life_analysis (insns, rtl_dump_file, PROP_FINAL);
2817 cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0) | CLEANUP_UPDATE_LIFE
2819 | (flag_thread_jumps ? CLEANUP_THREADING : 0));
2820 timevar_pop (TV_FLOW);
2822 if (warn_uninitialized)
2824 uninitialized_vars_warning (DECL_INITIAL (decl));
2826 setjmp_args_warning ();
2831 if (!flag_new_regalloc && initialize_uninitialized_subregs ())
2833 /* Insns were inserted, and possibly pseudos created, so
2834 things might look a bit different. */
2835 insns = get_insns ();
2836 allocate_reg_life_data ();
2837 update_life_info (NULL, UPDATE_LIFE_GLOBAL_RM_NOTES,
2838 PROP_LOG_LINKS | PROP_REG_INFO | PROP_DEATH_NOTES);
2844 close_dump_file (DFI_life, print_rtl_with_bb, insns);
2849 /* Perform common subexpression elimination. Nonzero value from
2850 `cse_main' means that jumps were simplified and some code may now
2851 be unreachable, so do jump optimization again. */
2853 rest_of_handle_cse (tree decl, rtx insns)
2857 open_dump_file (DFI_cse, decl);
2859 dump_flow_info (rtl_dump_file);
2860 timevar_push (TV_CSE);
2862 reg_scan (insns, max_reg_num (), 1);
2864 tem = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
2866 rebuild_jump_labels (insns);
2867 if (purge_all_dead_edges (0))
2868 delete_unreachable_blocks ();
2870 delete_trivially_dead_insns (insns, max_reg_num ());
2872 /* If we are not running more CSE passes, then we are no longer
2873 expecting CSE to be run. But always rerun it in a cheap mode. */
2874 cse_not_expected = !flag_rerun_cse_after_loop && !flag_gcse;
2876 if (tem || optimize > 1)
2877 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2878 /* Try to identify useless null pointer tests and delete them. */
2879 if (flag_delete_null_pointer_checks)
2881 timevar_push (TV_JUMP);
2883 if (delete_null_pointer_checks (insns))
2884 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2885 timevar_pop (TV_JUMP);
2888 /* The second pass of jump optimization is likely to have
2889 removed a bunch more instructions. */
2890 renumber_insns (rtl_dump_file);
2892 timevar_pop (TV_CSE);
2893 close_dump_file (DFI_cse, print_rtl_with_bb, insns);
2896 /* Run second CSE pass after loop optimizations. */
2898 rest_of_handle_cse2 (tree decl, rtx insns)
2902 timevar_push (TV_CSE2);
2903 open_dump_file (DFI_cse2, decl);
2905 dump_flow_info (rtl_dump_file);
2906 /* CFG is no longer maintained up-to-date. */
2907 tem = cse_main (insns, max_reg_num (), 1, rtl_dump_file);
2909 /* Run a pass to eliminate duplicated assignments to condition code
2910 registers. We have to run this after bypass_jumps, because it
2911 makes it harder for that pass to determine whether a jump can be
2913 cse_condition_code_reg ();
2915 purge_all_dead_edges (0);
2916 delete_trivially_dead_insns (insns, max_reg_num ());
2920 timevar_push (TV_JUMP);
2921 rebuild_jump_labels (insns);
2922 cleanup_cfg (CLEANUP_EXPENSIVE);
2923 timevar_pop (TV_JUMP);
2925 reg_scan (insns, max_reg_num (), 0);
2926 close_dump_file (DFI_cse2, print_rtl_with_bb, insns);
2928 timevar_pop (TV_CSE2);
2931 /* Perform global cse. */
2933 rest_of_handle_gcse (tree decl, rtx insns)
2935 int save_csb, save_cfj;
2938 timevar_push (TV_GCSE);
2939 open_dump_file (DFI_gcse, decl);
2941 tem = gcse_main (insns, rtl_dump_file);
2942 rebuild_jump_labels (insns);
2943 delete_trivially_dead_insns (insns, max_reg_num ());
2945 save_csb = flag_cse_skip_blocks;
2946 save_cfj = flag_cse_follow_jumps;
2947 flag_cse_skip_blocks = flag_cse_follow_jumps = 0;
2949 /* Instantiate any remaining CONSTANT_P_RTX nodes. */
2950 if (current_function_calls_constant_p)
2951 purge_builtin_constant_p ();
2953 /* If -fexpensive-optimizations, re-run CSE to clean up things done
2955 if (flag_expensive_optimizations)
2957 timevar_push (TV_CSE);
2958 reg_scan (insns, max_reg_num (), 1);
2959 tem2 = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
2960 purge_all_dead_edges (0);
2961 delete_trivially_dead_insns (insns, max_reg_num ());
2962 timevar_pop (TV_CSE);
2963 cse_not_expected = !flag_rerun_cse_after_loop;
2966 /* If gcse or cse altered any jumps, rerun jump optimizations to clean
2967 things up. Then possibly re-run CSE again. */
2971 timevar_push (TV_JUMP);
2972 rebuild_jump_labels (insns);
2973 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
2974 timevar_pop (TV_JUMP);
2976 if (flag_expensive_optimizations)
2978 timevar_push (TV_CSE);
2979 reg_scan (insns, max_reg_num (), 1);
2980 tem2 = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
2981 purge_all_dead_edges (0);
2982 delete_trivially_dead_insns (insns, max_reg_num ());
2983 timevar_pop (TV_CSE);
2987 close_dump_file (DFI_gcse, print_rtl_with_bb, insns);
2988 timevar_pop (TV_GCSE);
2991 flag_cse_skip_blocks = save_csb;
2992 flag_cse_follow_jumps = save_cfj;
2993 #ifdef ENABLE_CHECKING
2994 verify_flow_info ();
2998 /* Move constant computations out of loops. */
3000 rest_of_handle_loop_optimize (tree decl, rtx insns)
3002 int do_unroll, do_prefetch;
3004 timevar_push (TV_LOOP);
3005 delete_dead_jumptables ();
3006 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
3007 open_dump_file (DFI_loop, decl);
3009 /* CFG is no longer maintained up-to-date. */
3010 free_bb_for_insn ();
3012 if (flag_unroll_loops)
3013 do_unroll = LOOP_AUTO_UNROLL; /* Having two unrollers is useless. */
3015 do_unroll = flag_old_unroll_loops ? LOOP_UNROLL : LOOP_AUTO_UNROLL;
3016 do_prefetch = flag_prefetch_loop_arrays ? LOOP_PREFETCH : 0;
3018 if (flag_rerun_loop_opt)
3020 cleanup_barriers ();
3022 /* We only want to perform unrolling once. */
3023 loop_optimize (insns, rtl_dump_file, do_unroll);
3026 /* The first call to loop_optimize makes some instructions
3027 trivially dead. We delete those instructions now in the
3028 hope that doing so will make the heuristics in loop work
3029 better and possibly speed up compilation. */
3030 delete_trivially_dead_insns (insns, max_reg_num ());
3032 /* The regscan pass is currently necessary as the alias
3033 analysis code depends on this information. */
3034 reg_scan (insns, max_reg_num (), 1);
3036 cleanup_barriers ();
3037 loop_optimize (insns, rtl_dump_file, do_unroll | LOOP_BCT | do_prefetch);
3039 /* Loop can create trivially dead instructions. */
3040 delete_trivially_dead_insns (insns, max_reg_num ());
3041 close_dump_file (DFI_loop, print_rtl, insns);
3042 timevar_pop (TV_LOOP);
3043 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3048 /* Perform loop optimizations. It might be better to do them a bit
3049 sooner, but we want the profile feedback to work more
3052 rest_of_handle_loop2 (tree decl, rtx insns)
3054 struct loops *loops;
3057 timevar_push (TV_LOOP);
3058 open_dump_file (DFI_loop2, decl);
3060 dump_flow_info (rtl_dump_file);
3062 /* Initialize structures for layout changes. */
3063 cfg_layout_initialize ();
3065 loops = loop_optimizer_init (rtl_dump_file);
3069 /* The optimizations: */
3070 if (flag_unswitch_loops)
3071 unswitch_loops (loops);
3073 if (flag_peel_loops || flag_unroll_loops)
3074 unroll_and_peel_loops (loops,
3075 (flag_peel_loops ? UAP_PEEL : 0) |
3076 (flag_unroll_loops ? UAP_UNROLL : 0) |
3077 (flag_unroll_all_loops ? UAP_UNROLL_ALL : 0));
3079 loop_optimizer_finalize (loops, rtl_dump_file);
3082 /* Finalize layout changes. */
3084 if (bb->next_bb != EXIT_BLOCK_PTR)
3085 bb->rbi->next = bb->next_bb;
3086 cfg_layout_finalize ();
3088 cleanup_cfg (CLEANUP_EXPENSIVE);
3089 delete_trivially_dead_insns (insns, max_reg_num ());
3090 reg_scan (insns, max_reg_num (), 0);
3092 dump_flow_info (rtl_dump_file);
3093 close_dump_file (DFI_loop2, print_rtl_with_bb, get_insns ());
3094 timevar_pop (TV_LOOP);
3098 /* This is called from finish_function (within langhooks.parse_file)
3099 after each top-level definition is parsed.
3100 It is supposed to compile that function or variable
3101 and output the assembler code for it.
3102 After we return, the tree storage is freed. */
3105 rest_of_compilation (tree decl)
3109 timevar_push (TV_REST_OF_COMPILATION);
3111 /* Register rtl specific functions for cfg. */
3112 rtl_register_cfg_hooks ();
3114 /* Now that we're out of the frontend, we shouldn't have any more
3115 CONCATs anywhere. */
3116 generating_concat_p = 0;
3118 /* When processing delayed functions, prepare_function_start() won't
3119 have been run to re-initialize it. */
3120 cse_not_expected = ! optimize;
3122 /* First, make sure that NOTE_BLOCK is set correctly for each
3123 NOTE_INSN_BLOCK_BEG/NOTE_INSN_BLOCK_END note. */
3124 if (!cfun->x_whole_function_mode_p)
3127 /* In function-at-a-time mode, we do not attempt to keep the BLOCK
3128 tree in sensible shape. So, we just recalculate it here. */
3129 if (cfun->x_whole_function_mode_p)
3134 if (rest_of_handle_inlining (decl))
3135 goto exit_rest_of_compilation;
3137 /* If we're emitting a nested function, make sure its parent gets
3138 emitted as well. Doing otherwise confuses debug info. */
3141 for (parent = DECL_CONTEXT (current_function_decl);
3142 parent != NULL_TREE;
3143 parent = get_containing_scope (parent))
3144 if (TREE_CODE (parent) == FUNCTION_DECL)
3145 TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (parent)) = 1;
3148 /* We are now committed to emitting code for this function. Do any
3149 preparation, such as emitting abstract debug info for the inline
3150 before it gets mangled by optimization. */
3151 if (cgraph_function_possibly_inlined_p (decl))
3152 (*debug_hooks->outlining_inline_function) (decl);
3154 /* Remove any notes we don't need. That will make iterating
3155 over the instruction sequence faster, and allow the garbage
3156 collector to reclaim the memory used by the notes. */
3157 remove_unnecessary_notes ();
3162 /* Initialize some variables used by the optimizers. */
3163 init_function_for_compilation ();
3165 if (! DECL_DEFER_OUTPUT (decl))
3166 TREE_ASM_WRITTEN (decl) = 1;
3168 /* Now that integrate will no longer see our rtl, we need not
3169 distinguish between the return value of this function and the
3170 return value of called functions. Also, we can remove all SETs
3171 of subregs of hard registers; they are only here because of
3172 integrate. Also, we can now initialize pseudos intended to
3173 carry magic hard reg data throughout the function. */
3174 rtx_equal_function_value_matters = 0;
3175 purge_hard_subreg_sets (get_insns ());
3177 /* Early return if there were errors. We can run afoul of our
3178 consistency checks, and there's not really much point in fixing them.
3179 Don't return yet if -Wreturn-type; we need to do cleanup_cfg. */
3180 if (((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type)
3181 || errorcount || sorrycount)
3182 goto exit_rest_of_compilation;
3184 timevar_push (TV_JUMP);
3185 open_dump_file (DFI_sibling, decl);
3186 insns = get_insns ();
3187 rebuild_jump_labels (insns);
3188 find_exception_handler_labels ();
3189 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3191 delete_unreachable_blocks ();
3193 /* Turn NOTE_INSN_PREDICTIONs into branch predictions. */
3194 if (flag_guess_branch_prob)
3196 timevar_push (TV_BRANCH_PROB);
3197 note_prediction_to_br_prob ();
3198 timevar_pop (TV_BRANCH_PROB);
3201 if (flag_optimize_sibling_calls)
3202 rest_of_handle_sibling_calls (insns);
3204 /* We have to issue these warnings now already, because CFG cleanups
3205 further down may destroy the required information. However, this
3206 must be done after the sibcall optimization pass because the barrier
3207 emitted for noreturn calls that are candidate for the optimization
3208 is folded into the CALL_PLACEHOLDER until after this pass, so the
3209 CFG is inaccurate. */
3210 check_function_return_warnings ();
3212 timevar_pop (TV_JUMP);
3214 insn_locators_initialize ();
3215 /* Complete generation of exception handling code. */
3218 timevar_push (TV_JUMP);
3219 open_dump_file (DFI_eh, decl);
3221 finish_eh_generation ();
3223 close_dump_file (DFI_eh, print_rtl, get_insns ());
3224 timevar_pop (TV_JUMP);
3227 /* Delay emitting hard_reg_initial_value sets until after EH landing pad
3228 generation, which might create new sets. */
3229 emit_initial_value_sets ();
3232 /* If we are doing position-independent code generation, now
3233 is the time to output special prologues and epilogues.
3234 We do not want to do this earlier, because it just clutters
3235 up inline functions with meaningless insns. */
3240 insns = get_insns ();
3242 /* Copy any shared structure that should not be shared. */
3243 unshare_all_rtl (current_function_decl, insns);
3245 #ifdef SETJMP_VIA_SAVE_AREA
3246 /* This must be performed before virtual register instantiation.
3247 Please be aware the everything in the compiler that can look
3248 at the RTL up to this point must understand that REG_SAVE_AREA
3249 is just like a use of the REG contained inside. */
3250 if (current_function_calls_alloca)
3251 optimize_save_area_alloca (insns);
3254 /* Instantiate all virtual registers. */
3255 instantiate_virtual_regs (current_function_decl, insns);
3257 open_dump_file (DFI_jump, decl);
3259 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields
3260 are initialized and to compute whether control can drop off the end
3263 timevar_push (TV_JUMP);
3264 /* Turn NOTE_INSN_EXPECTED_VALUE into REG_BR_PROB. Do this
3265 before jump optimization switches branch directions. */
3266 if (flag_guess_branch_prob)
3267 expected_value_to_br_prob ();
3269 reg_scan (insns, max_reg_num (), 0);
3270 rebuild_jump_labels (insns);
3271 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3272 delete_trivially_dead_insns (insns, max_reg_num ());
3274 dump_flow_info (rtl_dump_file);
3275 cleanup_cfg ((optimize ? CLEANUP_EXPENSIVE : 0) | CLEANUP_PRE_LOOP
3276 | (flag_thread_jumps ? CLEANUP_THREADING : 0));
3280 free_bb_for_insn ();
3281 copy_loop_headers (insns);
3282 find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
3284 purge_line_number_notes (insns);
3286 timevar_pop (TV_JUMP);
3287 close_dump_file (DFI_jump, print_rtl, insns);
3289 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */
3290 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl))
3291 goto exit_rest_of_compilation;
3293 timevar_push (TV_JUMP);
3296 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP);
3298 if (flag_delete_null_pointer_checks)
3299 rest_of_handle_null_pointer (decl, insns);
3301 /* Jump optimization, and the removal of NULL pointer checks, may
3302 have reduced the number of instructions substantially. CSE, and
3303 future passes, allocate arrays whose dimensions involve the
3304 maximum instruction UID, so if we can reduce the maximum UID
3305 we'll save big on memory. */
3306 renumber_insns (rtl_dump_file);
3307 timevar_pop (TV_JUMP);
3309 close_dump_file (DFI_jump, print_rtl_with_bb, insns);
3314 rest_of_handle_cse (decl, insns);
3316 rest_of_handle_addressof (decl, insns);
3323 rest_of_handle_gcse (decl, insns);
3325 if (flag_loop_optimize)
3326 rest_of_handle_loop_optimize (decl, insns);
3329 rest_of_handle_jump_bypass (decl, insns);
3332 timevar_push (TV_FLOW);
3334 rest_of_handle_cfg (decl, insns);
3337 || profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
3339 rest_of_handle_branch_prob (decl, insns);
3341 if (flag_branch_probabilities
3342 && flag_profile_values
3343 && flag_value_profile_transformations)
3344 rest_of_handle_value_profile_transformations (decl, insns);
3346 /* Remove the death notes created for vpt. */
3347 if (flag_profile_values)
3348 count_or_remove_death_notes (NULL, 1);
3352 rest_of_handle_if_conversion (decl, insns);
3355 rest_of_handle_tracer (decl, insns);
3358 && (flag_unswitch_loops
3360 || flag_unroll_loops))
3361 rest_of_handle_loop2 (decl, insns);
3364 rest_of_handle_web (decl, insns);
3366 if (flag_rerun_cse_after_loop)
3367 rest_of_handle_cse2 (decl, insns);
3369 cse_not_expected = 1;
3371 rest_of_handle_life (decl, insns);
3374 rest_of_handle_combine (decl, insns);
3376 if (flag_if_conversion)
3377 rest_of_handle_if_after_combine (decl, insns);
3379 if (optimize > 0 && (flag_regmove || flag_expensive_optimizations))
3380 rest_of_handle_regmove (decl, insns);
3382 /* Do unconditional splitting before register allocation to allow machine
3383 description to add extra information not needed previously. */
3384 split_all_insns (1);
3386 #ifdef OPTIMIZE_MODE_SWITCHING
3387 timevar_push (TV_MODE_SWITCH);
3390 optimize_mode_switching (NULL);
3393 timevar_pop (TV_MODE_SWITCH);
3396 /* Any of the several passes since flow1 will have munged register
3397 lifetime data a bit. We need it to be up to date for scheduling
3398 (see handling of reg_known_equiv in init_alias_analysis). */
3399 recompute_reg_usage (insns, !optimize_size);
3401 #ifdef INSN_SCHEDULING
3402 rest_of_handle_sched (decl, insns);
3405 /* Determine if the current function is a leaf before running reload
3406 since this can impact optimizations done by the prologue and
3407 epilogue thus changing register elimination offsets. */
3408 current_function_is_leaf = leaf_function_p ();
3410 timevar_push (TV_LOCAL_ALLOC);
3411 open_dump_file (DFI_lreg, decl);
3413 if (flag_new_regalloc)
3415 if (rest_of_handle_new_regalloc (decl, insns))
3416 goto exit_rest_of_compilation;
3420 if (rest_of_handle_old_regalloc (decl, insns))
3421 goto exit_rest_of_compilation;
3426 open_dump_file (DFI_postreload, decl);
3428 /* Do a very simple CSE pass over just the hard registers. */
3431 timevar_push (TV_RELOAD_CSE_REGS);
3432 reload_cse_regs (insns);
3433 /* reload_cse_regs can eliminate potentially-trapping MEMs.
3434 Remove any EH edges associated with them. */
3435 if (flag_non_call_exceptions)
3436 purge_all_dead_edges (0);
3437 timevar_pop (TV_RELOAD_CSE_REGS);
3440 close_dump_file (DFI_postreload, print_rtl_with_bb, insns);
3442 /* Re-create the death notes which were deleted during reload. */
3443 timevar_push (TV_FLOW2);
3444 open_dump_file (DFI_flow2, decl);
3446 #ifdef ENABLE_CHECKING
3447 verify_flow_info ();
3450 /* If optimizing, then go ahead and split insns now. */
3454 split_all_insns (0);
3456 if (flag_branch_target_load_optimize)
3458 open_dump_file (DFI_branch_target_load, decl);
3460 branch_target_load_optimize (insns, false);
3462 close_dump_file (DFI_branch_target_load, print_rtl_with_bb, insns);
3468 cleanup_cfg (CLEANUP_EXPENSIVE);
3470 /* On some machines, the prologue and epilogue code, or parts thereof,
3471 can be represented as RTL. Doing so lets us schedule insns between
3472 it and the rest of the code and also allows delayed branch
3473 scheduling to operate in the epilogue. */
3474 thread_prologue_and_epilogue_insns (insns);
3475 epilogue_completed = 1;
3479 life_analysis (insns, rtl_dump_file, PROP_POSTRELOAD);
3480 cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE
3481 | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0));
3483 /* This is kind of a heuristic. We need to run combine_stack_adjustments
3484 even for machines with possibly nonzero RETURN_POPS_ARGS
3485 and ACCUMULATE_OUTGOING_ARGS. We expect that only ports having
3486 push instructions will have popping returns. */
3487 #ifndef PUSH_ROUNDING
3488 if (!ACCUMULATE_OUTGOING_ARGS)
3490 combine_stack_adjustments ();
3495 flow2_completed = 1;
3497 close_dump_file (DFI_flow2, print_rtl_with_bb, insns);
3498 timevar_pop (TV_FLOW2);
3500 #ifdef HAVE_peephole2
3501 if (optimize > 0 && flag_peephole2)
3503 timevar_push (TV_PEEPHOLE2);
3504 open_dump_file (DFI_peephole2, decl);
3506 peephole2_optimize (rtl_dump_file);
3508 close_dump_file (DFI_peephole2, print_rtl_with_bb, insns);
3509 timevar_pop (TV_PEEPHOLE2);
3513 open_dump_file (DFI_ce3, decl);
3515 /* Last attempt to optimize CFG, as scheduling, peepholing and insn
3516 splitting possibly introduced more crossjumping opportunities. */
3517 cleanup_cfg (CLEANUP_EXPENSIVE
3518 | CLEANUP_UPDATE_LIFE
3519 | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0));
3520 if (flag_if_conversion2)
3522 timevar_push (TV_IFCVT2);
3526 timevar_pop (TV_IFCVT2);
3528 close_dump_file (DFI_ce3, print_rtl_with_bb, insns);
3532 if (flag_rename_registers || flag_cprop_registers)
3533 rest_of_handle_regrename (decl, insns);
3535 rest_of_handle_reorder_blocks (decl, insns);
3538 if (flag_branch_target_load_optimize2)
3540 /* Leave this a warning for now so that it is possible to experiment
3541 with running this pass twice. In 3.6, we should either make this
3542 an error, or use separate dump files. */
3543 if (flag_branch_target_load_optimize)
3544 warning ("branch target register load optimization is not intended "
3547 open_dump_file (DFI_branch_target_load, decl);
3549 branch_target_load_optimize (insns, true);
3551 close_dump_file (DFI_branch_target_load, print_rtl_with_bb, insns);
3556 #ifdef INSN_SCHEDULING
3557 if (optimize > 0 && flag_schedule_insns_after_reload)
3558 rest_of_handle_sched2 (decl, insns);
3561 #ifdef LEAF_REGISTERS
3562 current_function_uses_only_leaf_regs
3563 = optimize > 0 && only_leaf_regs_used () && leaf_function_p ();
3567 rest_of_handle_stack_regs (decl, insns);
3570 compute_alignments ();
3572 if (flag_var_tracking)
3573 rest_of_handle_variable_tracking (decl, insns);
3575 /* CFG is no longer maintained up-to-date. */
3576 free_bb_for_insn ();
3578 if (targetm.machine_dependent_reorg != 0)
3579 rest_of_handle_machine_reorg (decl, insns);
3581 purge_line_number_notes (insns);
3582 cleanup_barriers ();
3585 if (optimize > 0 && flag_delayed_branch)
3586 rest_of_handle_delay_slots (decl, insns);
3589 #if defined (HAVE_ATTR_length) && !defined (STACK_REGS)
3590 timevar_push (TV_SHORTEN_BRANCH);
3591 split_all_insns_noflow ();
3592 timevar_pop (TV_SHORTEN_BRANCH);
3595 convert_to_eh_region_ranges ();
3597 /* Shorten branches. */
3598 timevar_push (TV_SHORTEN_BRANCH);
3599 shorten_branches (get_insns ());
3600 timevar_pop (TV_SHORTEN_BRANCH);
3602 set_nothrow_function_flags ();
3603 if (current_function_nothrow)
3604 /* Now we know that this can't throw; set the flag for the benefit
3605 of other functions later in this translation unit. */
3606 TREE_NOTHROW (current_function_decl) = 1;
3608 rest_of_handle_final (decl, insns);
3610 /* Write DBX symbols if requested. */
3612 /* Note that for those inline functions where we don't initially
3613 know for certain that we will be generating an out-of-line copy,
3614 the first invocation of this routine (rest_of_compilation) will
3615 skip over this code by doing a `goto exit_rest_of_compilation;'.
3616 Later on, wrapup_global_declarations will (indirectly) call
3617 rest_of_compilation again for those inline functions that need
3618 to have out-of-line copies generated. During that call, we
3619 *will* be routed past here. */
3621 timevar_push (TV_SYMOUT);
3622 (*debug_hooks->function_decl) (decl);
3623 timevar_pop (TV_SYMOUT);
3625 exit_rest_of_compilation:
3627 coverage_end_function ();
3629 /* In case the function was not output,
3630 don't leave any temporary anonymous types
3631 queued up for sdb output. */
3632 #ifdef SDB_DEBUGGING_INFO
3633 if (write_symbols == SDB_DEBUG)
3634 sdbout_types (NULL_TREE);
3637 reload_completed = 0;
3638 epilogue_completed = 0;
3639 flow2_completed = 0;
3642 timevar_push (TV_FINAL);
3644 /* Clear out the insn_length contents now that they are no
3646 init_insn_lengths ();
3648 /* Show no temporary slots allocated. */
3651 free_basic_block_vars (0);
3652 free_bb_for_insn ();
3654 timevar_pop (TV_FINAL);
3656 if ((*targetm.binds_local_p) (current_function_decl))
3658 int pref = cfun->preferred_stack_boundary;
3659 if (cfun->recursive_call_emit
3660 && cfun->stack_alignment_needed > cfun->preferred_stack_boundary)
3661 pref = cfun->stack_alignment_needed;
3662 cgraph_rtl_info (current_function_decl)->preferred_incoming_stack_boundary
3666 /* Make sure volatile mem refs aren't considered valid operands for
3667 arithmetic insns. We must call this here if this is a nested inline
3668 function, since the above code leaves us in the init_recog state
3669 (from final.c), and the function context push/pop code does not
3670 save/restore volatile_ok.
3672 ??? Maybe it isn't necessary for expand_start_function to call this
3673 anymore if we do it here? */
3675 init_recog_no_volatile ();
3677 /* We're done with this function. Free up memory if we can. */
3678 free_after_parsing (cfun);
3679 if (! DECL_DEFER_OUTPUT (decl))
3681 free_after_compilation (cfun);
3682 DECL_STRUCT_FUNCTION (decl) = 0;
3688 timevar_pop (TV_REST_OF_COMPILATION);
3691 /* Display help for target options. */
3693 display_target_options (void)
3696 static bool displayed = false;
3698 /* Avoid double printing for --help --target-help. */
3704 if (ARRAY_SIZE (target_switches) > 1
3705 #ifdef TARGET_OPTIONS
3706 || ARRAY_SIZE (target_options) > 1
3714 printf (_("\nTarget specific options:\n"));
3716 for (i = ARRAY_SIZE (target_switches); i--;)
3718 const char *option = target_switches[i].name;
3719 const char *description = target_switches[i].description;
3721 if (option == NULL || *option == 0)
3723 else if (description == NULL)
3728 printf (_(" -m%-23s [undocumented]\n"), option);
3730 else if (*description != 0)
3731 doc += printf (" -m%-23s %s\n", option, _(description));
3734 #ifdef TARGET_OPTIONS
3735 for (i = ARRAY_SIZE (target_options); i--;)
3737 const char *option = target_options[i].prefix;
3738 const char *description = target_options[i].description;
3740 if (option == NULL || *option == 0)
3742 else if (description == NULL)
3747 printf (_(" -m%-23s [undocumented]\n"), option);
3749 else if (*description != 0)
3750 doc += printf (" -m%-23s %s\n", option, _(description));
3756 printf (_("\nThere are undocumented target specific options as well.\n"));
3758 printf (_(" They exist, but they are not documented.\n"));
3763 /* Parse a -d... command line switch. */
3766 decode_d_option (const char *arg)
3774 for (i = 0; i < (int) DFI_MAX; ++i)
3775 dump_file[i].enabled = 1;
3781 flag_print_asm_name = 1;
3784 flag_dump_rtl_in_asm = 1;
3785 flag_print_asm_name = 1;
3788 graph_dump_format = vcg;
3791 rtl_dump_and_exit = 1;
3796 case 'D': /* These are handled by the preprocessor. */
3800 setup_core_dumping();
3805 for (i = 0; i < (int) DFI_MAX; ++i)
3806 if (c == dump_file[i].debug_switch)
3808 dump_file[i].enabled = 1;
3813 warning ("unrecognized gcc debugging option: %c", c);
3818 /* Indexed by enum debug_info_type. */
3819 const char *const debug_type_names[] =
3821 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff", "vms"
3824 /* Decode -m switches. */
3825 /* Decode the switch -mNAME. */
3828 set_target_switch (const char *name)
3831 int valid_target_option = 0;
3833 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
3834 if (!strcmp (target_switches[j].name, name))
3836 if (target_switches[j].value < 0)
3837 target_flags &= ~-target_switches[j].value;
3839 target_flags |= target_switches[j].value;
3842 if (target_switches[j].value < 0)
3843 target_flags_explicit |= -target_switches[j].value;
3845 target_flags_explicit |= target_switches[j].value;
3847 valid_target_option = 1;
3850 #ifdef TARGET_OPTIONS
3851 if (!valid_target_option)
3852 for (j = 0; j < ARRAY_SIZE (target_options); j++)
3854 int len = strlen (target_options[j].prefix);
3855 if (target_options[j].value)
3857 if (!strcmp (target_options[j].prefix, name))
3859 *target_options[j].variable = target_options[j].value;
3860 valid_target_option = 1;
3865 if (!strncmp (target_options[j].prefix, name, len))
3867 *target_options[j].variable = name + len;
3868 valid_target_option = 1;
3874 if (!valid_target_option)
3875 error ("invalid option `%s'", name);
3878 /* Print version information to FILE.
3879 Each line begins with INDENT (for the case where FILE is the
3880 assembler output file). */
3883 print_version (FILE *file, const char *indent)
3886 #define __VERSION__ "[?]"
3890 "%s%s%s version %s (%s)\n%s\tcompiled by GNU C version %s.\n"
3892 "%s%s%s version %s (%s) compiled by CC.\n"
3894 , indent, *indent != 0 ? " " : "",
3895 lang_hooks.name, version_string, TARGET_NAME,
3896 indent, __VERSION__);
3897 fnotice (file, "%s%sGGC heuristics: --param ggc-min-expand=%d --param ggc-min-heapsize=%d\n",
3898 indent, *indent != 0 ? " " : "",
3899 PARAM_VALUE (GGC_MIN_EXPAND), PARAM_VALUE (GGC_MIN_HEAPSIZE));
3902 /* Print an option value and return the adjusted position in the line.
3903 ??? We don't handle error returns from fprintf (disk full); presumably
3904 other code will catch a disk full though. */
3907 print_single_switch (FILE *file, int pos, int max,
3908 const char *indent, const char *sep, const char *term,
3909 const char *type, const char *name)
3911 /* The ultrix fprintf returns 0 on success, so compute the result we want
3912 here since we need it for the following test. */
3913 int len = strlen (sep) + strlen (type) + strlen (name);
3918 fprintf (file, "%s", term);
3923 fprintf (file, "%s", indent);
3924 pos = strlen (indent);
3926 fprintf (file, "%s%s%s", sep, type, name);
3931 /* Print active target switches to FILE.
3932 POS is the current cursor position and MAX is the size of a "line".
3933 Each line begins with INDENT and ends with TERM.
3934 Each switch is separated from the next by SEP. */
3937 print_switch_values (FILE *file, int pos, int max,
3938 const char *indent, const char *sep, const char *term)
3943 /* Fill in the -frandom-seed option, if the user didn't pass it, so
3944 that it can be printed below. This helps reproducibility. */
3947 /* Print the options as passed. */
3948 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
3949 _("options passed: "), "");
3951 for (p = &save_argv[1]; *p != NULL; p++)
3955 if (strcmp (*p, "-o") == 0)
3961 if (strcmp (*p, "-quiet") == 0)
3963 if (strcmp (*p, "-version") == 0)
3968 pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
3971 fprintf (file, "%s", term);
3973 /* Print the -f and -m options that have been enabled.
3974 We don't handle language specific options but printing argv
3977 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
3978 _("options enabled: "), "");
3980 for (j = 0; j < ARRAY_SIZE (f_options); j++)
3981 if (*f_options[j].variable == f_options[j].on_value)
3982 pos = print_single_switch (file, pos, max, indent, sep, term,
3983 "-f", f_options[j].string);
3985 /* Print target specific options. */
3987 for (j = 0; j < ARRAY_SIZE (target_switches); j++)
3988 if (target_switches[j].name[0] != '\0'
3989 && target_switches[j].value > 0
3990 && ((target_switches[j].value & target_flags)
3991 == target_switches[j].value))
3993 pos = print_single_switch (file, pos, max, indent, sep, term,
3994 "-m", target_switches[j].name);
3997 #ifdef TARGET_OPTIONS
3998 for (j = 0; j < ARRAY_SIZE (target_options); j++)
3999 if (*target_options[j].variable != NULL)
4002 sprintf (prefix, "-m%s", target_options[j].prefix);
4003 pos = print_single_switch (file, pos, max, indent, sep, term,
4004 prefix, *target_options[j].variable);
4008 fprintf (file, "%s", term);
4011 /* Open assembly code output file. Do this even if -fsyntax-only is
4012 on, because then the driver will have provided the name of a
4013 temporary file or bit bucket for us. NAME is the file specified on
4014 the command line, possibly NULL. */
4016 init_asm_output (const char *name)
4018 if (name == NULL && asm_file_name == 0)
4019 asm_out_file = stdout;
4022 if (asm_file_name == 0)
4024 int len = strlen (dump_base_name);
4025 char *dumpname = xmalloc (len + 6);
4026 memcpy (dumpname, dump_base_name, len + 1);
4027 strip_off_ending (dumpname, len);
4028 strcat (dumpname, ".s");
4029 asm_file_name = dumpname;
4031 if (!strcmp (asm_file_name, "-"))
4032 asm_out_file = stdout;
4034 asm_out_file = fopen (asm_file_name, "w+");
4035 if (asm_out_file == 0)
4036 fatal_error ("can't open %s for writing: %m", asm_file_name);
4039 #ifdef IO_BUFFER_SIZE
4040 setvbuf (asm_out_file, xmalloc (IO_BUFFER_SIZE),
4041 _IOFBF, IO_BUFFER_SIZE);
4044 if (!flag_syntax_only)
4046 targetm.asm_out.file_start ();
4048 #ifdef ASM_COMMENT_START
4049 if (flag_verbose_asm)
4051 /* Print the list of options in effect. */
4052 print_version (asm_out_file, ASM_COMMENT_START);
4053 print_switch_values (asm_out_file, 0, MAX_LINE,
4054 ASM_COMMENT_START, " ", "\n");
4055 /* Add a blank line here so it appears in assembler output but not
4057 fprintf (asm_out_file, "\n");
4063 /* Default version of get_pch_validity.
4064 By default, every flag difference is fatal; that will be mostly right for
4065 most targets, but completely right for very few. */
4068 default_get_pch_validity (size_t *len)
4070 #ifdef TARGET_OPTIONS
4075 *len = sizeof (target_flags) + 2;
4076 #ifdef TARGET_OPTIONS
4077 for (i = 0; i < ARRAY_SIZE (target_options); i++)
4080 if (*target_options[i].variable)
4081 *len += strlen (*target_options[i].variable);
4085 result = r = xmalloc (*len);
4089 memcpy (r, &target_flags, sizeof (target_flags));
4090 r += sizeof (target_flags);
4092 #ifdef TARGET_OPTIONS
4093 for (i = 0; i < ARRAY_SIZE (target_options); i++)
4095 const char *str = *target_options[i].variable;
4099 l = strlen (str) + 1;
4108 /* Default version of pch_valid_p. */
4111 default_pch_valid_p (const void *data_p, size_t len)
4113 const char *data = (const char *)data_p;
4114 const char *flag_that_differs = NULL;
4117 /* -fpic and -fpie also usually make a PCH invalid. */
4118 if (data[0] != flag_pic)
4119 return _("created and used with different settings of -fpic");
4120 if (data[1] != flag_pie)
4121 return _("created and used with different settings of -fpie");
4124 /* Check target_flags. */
4125 if (memcmp (data, &target_flags, sizeof (target_flags)) != 0)
4127 for (i = 0; i < ARRAY_SIZE (target_switches); i++)
4132 memcpy (&tf, data, sizeof (target_flags));
4134 bits = target_switches[i].value;
4137 if ((target_flags & bits) != (tf & bits))
4139 flag_that_differs = target_switches[i].name;
4145 data += sizeof (target_flags);
4146 len -= sizeof (target_flags);
4148 /* Check string options. */
4149 #ifdef TARGET_OPTIONS
4150 for (i = 0; i < ARRAY_SIZE (target_options); i++)
4152 const char *str = *target_options[i].variable;
4156 l = strlen (str) + 1;
4157 if (len < l || memcmp (data, str, l) != 0)
4159 flag_that_differs = target_options[i].prefix;
4172 asprintf (&r, _("created and used with differing settings of `-m%s'"),
4175 return _("out of memory");
4180 /* Default tree printer. Handles declarations only. */
4182 default_tree_printer (pretty_printer * pp, text_info *text)
4184 switch (*text->format_spec)
4190 tree t = va_arg (*text->args_ptr, tree);
4191 const char *n = DECL_NAME (t)
4192 ? (*lang_hooks.decl_printable_name) (t, 2)
4203 /* Initialization of the front end environment, before command line
4204 options are parsed. Signal handlers, internationalization etc.
4205 ARGV0 is main's argv[0]. */
4207 general_init (const char *argv0)
4211 p = argv0 + strlen (argv0);
4212 while (p != argv0 && !IS_DIR_SEPARATOR (p[-1]))
4216 xmalloc_set_program_name (progname);
4220 gcc_init_libintl ();
4222 /* Initialize the diagnostics reporting machinery, so option parsing
4223 can give warnings and errors. */
4224 diagnostic_initialize (global_dc);
4225 /* Set a default printer. Language specific initializations will
4226 override it later. */
4227 pp_format_decoder (global_dc->printer) = &default_tree_printer;
4229 /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages. */
4231 signal (SIGSEGV, crash_signal);
4234 signal (SIGILL, crash_signal);
4237 signal (SIGBUS, crash_signal);
4240 signal (SIGABRT, crash_signal);
4242 #if defined SIGIOT && (!defined SIGABRT || SIGABRT != SIGIOT)
4243 signal (SIGIOT, crash_signal);
4246 signal (SIGFPE, crash_signal);
4249 /* Other host-specific signal setup. */
4250 (*host_hooks.extra_signals)();
4252 /* Initialize the garbage-collector, string pools and tree type hash
4256 linemap_init (&line_table);
4259 /* Initialize register usage now so switches may override. */
4262 /* Register the language-independent parameters. */
4263 add_params (lang_independent_params, LAST_PARAM);
4265 /* This must be done after add_params but before argument processing. */
4266 init_ggc_heuristics();
4269 /* Process the options that have been parsed. */
4271 process_options (void)
4273 /* Allow the front end to perform consistency checks and do further
4274 initialization based on the command line options. This hook also
4275 sets the original filename if appropriate (e.g. foo.i -> foo.c)
4276 so we can correctly initialize debug output. */
4277 no_backend = (*lang_hooks.post_options) (&main_input_filename);
4278 input_filename = main_input_filename;
4280 #ifdef OVERRIDE_OPTIONS
4281 /* Some machines may reject certain combinations of options. */
4285 /* Set aux_base_name if not already set. */
4288 else if (main_input_filename)
4290 char *name = xstrdup (lbasename (main_input_filename));
4292 strip_off_ending (name, strlen (name));
4293 aux_base_name = name;
4296 aux_base_name = "gccaux";
4298 /* Set up the align_*_log variables, defaulting them to 1 if they
4299 were still unset. */
4300 if (align_loops <= 0) align_loops = 1;
4301 if (align_loops_max_skip > align_loops || !align_loops)
4302 align_loops_max_skip = align_loops - 1;
4303 align_loops_log = floor_log2 (align_loops * 2 - 1);
4304 if (align_jumps <= 0) align_jumps = 1;
4305 if (align_jumps_max_skip > align_jumps || !align_jumps)
4306 align_jumps_max_skip = align_jumps - 1;
4307 align_jumps_log = floor_log2 (align_jumps * 2 - 1);
4308 if (align_labels <= 0) align_labels = 1;
4309 align_labels_log = floor_log2 (align_labels * 2 - 1);
4310 if (align_labels_max_skip > align_labels || !align_labels)
4311 align_labels_max_skip = align_labels - 1;
4312 if (align_functions <= 0) align_functions = 1;
4313 align_functions_log = floor_log2 (align_functions * 2 - 1);
4315 /* Unrolling all loops implies that standard loop unrolling must also
4317 if (flag_unroll_all_loops)
4318 flag_unroll_loops = 1;
4320 if (flag_unroll_loops)
4322 flag_old_unroll_loops = 0;
4323 flag_old_unroll_all_loops = 0;
4326 if (flag_old_unroll_all_loops)
4327 flag_old_unroll_loops = 1;
4329 /* Old loop unrolling requires that strength_reduction be on also. Silently
4330 turn on strength reduction here if it isn't already on. Also, the loop
4331 unrolling code assumes that cse will be run after loop, so that must
4332 be turned on also. */
4333 if (flag_old_unroll_loops)
4335 flag_strength_reduce = 1;
4336 flag_rerun_cse_after_loop = 1;
4338 if (flag_unroll_loops || flag_peel_loops)
4339 flag_rerun_cse_after_loop = 1;
4341 if (flag_non_call_exceptions)
4342 flag_asynchronous_unwind_tables = 1;
4343 if (flag_asynchronous_unwind_tables)
4344 flag_unwind_tables = 1;
4346 /* Disable unit-at-a-time mode for frontends not supporting callgraph
4348 if (flag_unit_at_a_time && ! lang_hooks.callgraph.expand_function)
4349 flag_unit_at_a_time = 0;
4351 if (flag_value_profile_transformations)
4352 flag_profile_values = 1;
4354 /* Warn about options that are not supported on this machine. */
4355 #ifndef INSN_SCHEDULING
4356 if (flag_schedule_insns || flag_schedule_insns_after_reload)
4357 warning ("instruction scheduling not supported on this target machine");
4360 if (flag_delayed_branch)
4361 warning ("this target machine does not have delayed branches");
4364 user_label_prefix = USER_LABEL_PREFIX;
4365 if (flag_leading_underscore != -1)
4367 /* If the default prefix is more complicated than "" or "_",
4368 issue a warning and ignore this option. */
4369 if (user_label_prefix[0] == 0 ||
4370 (user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
4372 user_label_prefix = flag_leading_underscore ? "_" : "";
4375 warning ("-f%sleading-underscore not supported on this target machine",
4376 flag_leading_underscore ? "" : "no-");
4379 /* If we are in verbose mode, write out the version and maybe all the
4380 option flags in use. */
4383 print_version (stderr, "");
4385 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
4388 if (flag_syntax_only)
4390 write_symbols = NO_DEBUG;
4394 /* A lot of code assumes write_symbols == NO_DEBUG if the debugging
4396 if (debug_info_level == DINFO_LEVEL_NONE)
4397 write_symbols = NO_DEBUG;
4399 /* Now we know write_symbols, set up the debug hooks based on it.
4400 By default we do nothing for debug output. */
4401 if (write_symbols == NO_DEBUG)
4402 debug_hooks = &do_nothing_debug_hooks;
4403 #if defined(DBX_DEBUGGING_INFO)
4404 else if (write_symbols == DBX_DEBUG)
4405 debug_hooks = &dbx_debug_hooks;
4407 #if defined(XCOFF_DEBUGGING_INFO)
4408 else if (write_symbols == XCOFF_DEBUG)
4409 debug_hooks = &xcoff_debug_hooks;
4411 #ifdef SDB_DEBUGGING_INFO
4412 else if (write_symbols == SDB_DEBUG)
4413 debug_hooks = &sdb_debug_hooks;
4415 #ifdef DWARF2_DEBUGGING_INFO
4416 else if (write_symbols == DWARF2_DEBUG)
4417 debug_hooks = &dwarf2_debug_hooks;
4419 #ifdef VMS_DEBUGGING_INFO
4420 else if (write_symbols == VMS_DEBUG || write_symbols == VMS_AND_DWARF2_DEBUG)
4421 debug_hooks = &vmsdbg_debug_hooks;
4424 error ("target system does not support the \"%s\" debug format",
4425 debug_type_names[write_symbols]);
4427 /* Now we know which debug output will be used so we can set
4428 flag_var_tracking if user has not specified it. */
4429 if (flag_var_tracking == AUTODETECT_FLAG_VAR_TRACKING)
4431 /* User has not specified -f(no-)var-tracking so autodetect it. */
4433 = (optimize >= 1 && debug_info_level >= DINFO_LEVEL_NORMAL
4434 && debug_hooks->var_location != do_nothing_debug_hooks.var_location);
4437 /* If auxiliary info generation is desired, open the output file.
4438 This goes in the same directory as the source file--unlike
4439 all the other output files. */
4440 if (flag_gen_aux_info)
4442 aux_info_file = fopen (aux_info_file_name, "w");
4443 if (aux_info_file == 0)
4444 fatal_error ("can't open %s: %m", aux_info_file_name);
4447 if (! targetm.have_named_sections)
4449 if (flag_function_sections)
4451 warning ("-ffunction-sections not supported for this target");
4452 flag_function_sections = 0;
4454 if (flag_data_sections)
4456 warning ("-fdata-sections not supported for this target");
4457 flag_data_sections = 0;
4461 if (flag_function_sections && profile_flag)
4463 warning ("-ffunction-sections disabled; it makes profiling impossible");
4464 flag_function_sections = 0;
4467 #ifndef HAVE_prefetch
4468 if (flag_prefetch_loop_arrays)
4470 warning ("-fprefetch-loop-arrays not supported for this target");
4471 flag_prefetch_loop_arrays = 0;
4474 if (flag_prefetch_loop_arrays && !HAVE_prefetch)
4476 warning ("-fprefetch-loop-arrays not supported for this target (try -march switches)");
4477 flag_prefetch_loop_arrays = 0;
4481 /* This combination of options isn't handled for i386 targets and doesn't
4482 make much sense anyway, so don't allow it. */
4483 if (flag_prefetch_loop_arrays && optimize_size)
4485 warning ("-fprefetch-loop-arrays is not supported with -Os");
4486 flag_prefetch_loop_arrays = 0;
4489 #ifndef OBJECT_FORMAT_ELF
4490 if (flag_function_sections && write_symbols != NO_DEBUG)
4491 warning ("-ffunction-sections may affect debugging on some targets");
4494 /* The presence of IEEE signaling NaNs, implies all math can trap. */
4495 if (flag_signaling_nans)
4496 flag_trapping_math = 1;
4499 /* Initialize the compiler back end. */
4503 init_adjust_machine_modes ();
4505 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
4506 || debug_info_level == DINFO_LEVEL_VERBOSE
4507 #ifdef VMS_DEBUGGING_INFO
4508 /* Enable line number info for traceback. */
4509 || debug_info_level > DINFO_LEVEL_NONE
4511 || flag_test_coverage
4512 || warn_notreached);
4515 init_fake_stack_mems ();
4519 init_function_once ();
4520 init_varasm_once ();
4522 /* The following initialization functions need to generate rtl, so
4523 provide a dummy function context for them. */
4524 init_dummy_function_start ();
4526 if (flag_caller_saves)
4527 init_caller_save ();
4528 expand_dummy_function_end ();
4531 /* Language-dependent initialization. Returns nonzero on success. */
4533 lang_dependent_init (const char *name)
4535 if (dump_base_name == 0)
4536 dump_base_name = name ? name : "gccdump";
4538 /* Other front-end initialization. */
4539 if ((*lang_hooks.init) () == 0)
4542 init_asm_output (name);
4544 /* These create various _DECL nodes, so need to be called after the
4545 front end is initialized. */
4549 /* The following initialization functions need to generate rtl, so
4550 provide a dummy function context for them. */
4551 init_dummy_function_start ();
4553 expand_dummy_function_end ();
4555 /* If dbx symbol table desired, initialize writing it and output the
4556 predefined types. */
4557 timevar_push (TV_SYMOUT);
4559 #ifdef DWARF2_UNWIND_INFO
4560 if (dwarf2out_do_frame ())
4561 dwarf2out_frame_init ();
4564 /* Now we have the correct original filename, we can initialize
4566 (*debug_hooks->init) (name);
4568 timevar_pop (TV_SYMOUT);
4573 /* Clean up: close opened files, etc. */
4578 /* Close the dump files. */
4579 if (flag_gen_aux_info)
4581 fclose (aux_info_file);
4583 unlink (aux_info_file_name);
4586 /* Close non-debugging input and output files. Take special care to note
4587 whether fclose returns an error, since the pages might still be on the
4588 buffer chain while the file is open. */
4592 if (ferror (asm_out_file) != 0)
4593 fatal_error ("error writing to %s: %m", asm_file_name);
4594 if (fclose (asm_out_file) != 0)
4595 fatal_error ("error closing %s: %m", asm_file_name);
4598 /* Do whatever is necessary to finish printing the graphs. */
4599 if (graph_dump_format != no_graph)
4603 for (i = 0; i < (int) DFI_MAX; ++i)
4604 if (dump_file[i].initialized && dump_file[i].graph_dump_p)
4609 sprintf (seq, DUMPFILE_FORMAT, i);
4610 suffix = concat (seq, dump_file[i].extension, NULL);
4611 finish_graph_dump_file (dump_base_name, suffix);
4618 ggc_print_statistics ();
4619 stringpool_statistics ();
4620 dump_tree_statistics ();
4621 dump_rtx_statistics ();
4622 dump_varray_statistics ();
4623 dump_alloc_pool_statistics ();
4626 /* Free up memory for the benefit of leak detectors. */
4629 /* Language-specific end of compilation actions. */
4630 (*lang_hooks.finish) ();
4633 /* Initialize the compiler, and compile the input file. */
4637 /* Initialize timing first. The C front ends read the main file in
4638 the post_options hook, and C++ does file timings. */
4639 if (time_report || !quiet_flag || flag_detailed_statistics)
4641 timevar_start (TV_TOTAL);
4645 /* Don't do any more if an error has already occurred. */
4648 /* Set up the back-end if requested. */
4652 /* Language-dependent initialization. Returns true on success. */
4653 if (lang_dependent_init (main_input_filename))
4655 if (flag_unit_at_a_time)
4657 open_dump_file (DFI_cgraph, NULL);
4658 cgraph_dump_file = rtl_dump_file;
4659 rtl_dump_file = NULL;
4664 if (flag_unit_at_a_time)
4666 rtl_dump_file = cgraph_dump_file;
4667 cgraph_dump_file = NULL;
4668 close_dump_file (DFI_cgraph, NULL, NULL_RTX);
4675 /* Stop timing and print the times. */
4676 timevar_stop (TV_TOTAL);
4677 timevar_print (stderr);
4680 /* Entry point of cc1, cc1plus, jc1, f771, etc.
4681 Exit code is FATAL_EXIT_CODE if can't open files or if there were
4682 any errors, or SUCCESS_EXIT_CODE if compilation succeeded.
4684 It is not safe to call this function more than once. */
4687 toplev_main (unsigned int argc, const char **argv)
4691 /* Initialization of GCC's environment, and diagnostics. */
4692 general_init (argv[0]);
4694 /* Parse the options and do minimal processing; basically just
4695 enough to default flags appropriately. */
4696 decode_options (argc, argv);
4700 /* Exit early if we can (e.g. -help). */
4701 if (!exit_after_options)
4704 if (errorcount || sorrycount)
4705 return (FATAL_EXIT_CODE);
4707 return (SUCCESS_EXIT_CODE);