OSDN Git Service

Daily bump.
[pf3gnuchains/gcc-fork.git] / gcc / toplev.c
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, 2005, 2006, 2007, 2008
4    Free Software Foundation, Inc.
5
6 This file is part of GCC.
7
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
12
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16 for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3.  If not see
20 <http://www.gnu.org/licenses/>.  */
21
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.  */
26
27 #include "config.h"
28 #undef FLOAT /* This is for hpux. They should change hpux.  */
29 #undef FFS  /* Some systems define this in param.h.  */
30 #include "system.h"
31 #include "coretypes.h"
32 #include "tm.h"
33 #include <signal.h>
34
35 #ifdef HAVE_SYS_RESOURCE_H
36 # include <sys/resource.h>
37 #endif
38
39 #ifdef HAVE_SYS_TIMES_H
40 # include <sys/times.h>
41 #endif
42
43 #include "line-map.h"
44 #include "input.h"
45 #include "tree.h"
46 #include "version.h"
47 #include "rtl.h"
48 #include "tm_p.h"
49 #include "flags.h"
50 #include "insn-attr.h"
51 #include "insn-config.h"
52 #include "insn-flags.h"
53 #include "hard-reg-set.h"
54 #include "recog.h"
55 #include "output.h"
56 #include "except.h"
57 #include "function.h"
58 #include "toplev.h"
59 #include "expr.h"
60 #include "basic-block.h"
61 #include "intl.h"
62 #include "ggc.h"
63 #include "graph.h"
64 #include "regs.h"
65 #include "timevar.h"
66 #include "diagnostic.h"
67 #include "params.h"
68 #include "reload.h"
69 #include "ira.h"
70 #include "dwarf2asm.h"
71 #include "integrate.h"
72 #include "real.h"
73 #include "debug.h"
74 #include "target.h"
75 #include "langhooks.h"
76 #include "cfglayout.h"
77 #include "cfgloop.h"
78 #include "hosthooks.h"
79 #include "cgraph.h"
80 #include "opts.h"
81 #include "coverage.h"
82 #include "value-prof.h"
83 #include "alloc-pool.h"
84 #include "tree-mudflap.h"
85 #include "tree-pass.h"
86 #include "gimple.h"
87
88 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
89 #include "dwarf2out.h"
90 #endif
91
92 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
93 #include "dbxout.h"
94 #endif
95
96 #ifdef SDB_DEBUGGING_INFO
97 #include "sdbout.h"
98 #endif
99
100 #ifdef XCOFF_DEBUGGING_INFO
101 #include "xcoffout.h"           /* Needed for external data
102                                    declarations for e.g. AIX 4.x.  */
103 #endif
104
105 static void general_init (const char *);
106 static void do_compile (void);
107 static void process_options (void);
108 static void backend_init (void);
109 static int lang_dependent_init (const char *);
110 static void init_asm_output (const char *);
111 static void finalize (void);
112
113 static void crash_signal (int) ATTRIBUTE_NORETURN;
114 static void setup_core_dumping (void);
115 static void compile_file (void);
116
117 /* Nonzero to dump debug info whilst parsing (-dy option).  */
118 static int set_yydebug;
119
120 /* True if we don't need a backend (e.g. preprocessing only).  */
121 static bool no_backend;
122
123 /* Length of line when printing switch values.  */
124 #define MAX_LINE 75
125
126 /* Name of program invoked, sans directories.  */
127
128 const char *progname;
129
130 /* Copy of argument vector to toplev_main.  */
131 static const char **save_argv;
132
133 /* Name of top-level original source file (what was input to cpp).
134    This comes from the #-command at the beginning of the actual input.
135    If there isn't any there, then this is the cc1 input file name.  */
136
137 const char *main_input_filename;
138
139 /* Used to enable -fvar-tracking, -fweb and -frename-registers according
140    to optimize and default_debug_hooks in process_options ().  */
141 #define AUTODETECT_VALUE 2
142
143 /* Current position in real source file.  */
144
145 location_t input_location;
146
147 struct line_maps *line_table;
148
149 /* Name to use as base of names for dump output files.  */
150
151 const char *dump_base_name;
152
153 /* Name to use as a base for auxiliary output files.  */
154
155 const char *aux_base_name;
156
157 /* Prefix for profile data files */
158 const char *profile_data_prefix;
159
160 /* A mask of target_flags that includes bit X if X was set or cleared
161    on the command line.  */
162
163 int target_flags_explicit;
164
165 /* Debug hooks - dependent upon command line options.  */
166
167 const struct gcc_debug_hooks *debug_hooks;
168
169 /* Debug hooks - target default.  */
170
171 static const struct gcc_debug_hooks *default_debug_hooks;
172
173 /* Other flags saying which kinds of debugging dump have been requested.  */
174
175 int rtl_dump_and_exit;
176 int flag_print_asm_name;
177 enum graph_dump_types graph_dump_format;
178
179 /* Name for output file of assembly code, specified with -o.  */
180
181 const char *asm_file_name;
182
183 /* Nonzero means do optimizations.  -O.
184    Particular numeric values stand for particular amounts of optimization;
185    thus, -O2 stores 2 here.  However, the optimizations beyond the basic
186    ones are not controlled directly by this variable.  Instead, they are
187    controlled by individual `flag_...' variables that are defaulted
188    based on this variable.  */
189
190 int optimize = 0;
191
192 /* Nonzero means optimize for size.  -Os.
193    The only valid values are zero and nonzero. When optimize_size is
194    nonzero, optimize defaults to 2, but certain individual code
195    bloating optimizations are disabled.  */
196
197 int optimize_size = 0;
198
199 /* The FUNCTION_DECL for the function currently being compiled,
200    or 0 if between functions.  */
201 tree current_function_decl;
202
203 /* Set to the FUNC_BEGIN label of the current function, or NULL
204    if none.  */
205 const char * current_function_func_begin_label;
206
207 /* Nonzero means to collect statistics which might be expensive
208    and to print them when we are done.  */
209 int flag_detailed_statistics = 0;
210
211 /* A random sequence of characters, unless overridden by user.  */
212 static const char *flag_random_seed;
213
214 /* A local time stamp derived from the time of compilation. It will be
215    zero if the system cannot provide a time.  It will be -1u, if the
216    user has specified a particular random seed.  */
217 unsigned local_tick;
218
219 /* -f flags.  */
220
221 /* Nonzero means `char' should be signed.  */
222
223 int flag_signed_char;
224
225 /* Nonzero means give an enum type only as many bytes as it needs.  A value
226    of 2 means it has not yet been initialized.  */
227
228 int flag_short_enums;
229
230 /* Nonzero if structures and unions should be returned in memory.
231
232    This should only be defined if compatibility with another compiler or
233    with an ABI is needed, because it results in slower code.  */
234
235 #ifndef DEFAULT_PCC_STRUCT_RETURN
236 #define DEFAULT_PCC_STRUCT_RETURN 1
237 #endif
238
239 /* Nonzero for -fpcc-struct-return: return values the same way PCC does.  */
240
241 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
242
243 /* 0 means straightforward implementation of complex divide acceptable.
244    1 means wide ranges of inputs must work for complex divide.
245    2 means C99-like requirements for complex multiply and divide.  */
246
247 int flag_complex_method = 1;
248
249 /* Nonzero means we should be saving declaration info into a .X file.  */
250
251 int flag_gen_aux_info = 0;
252
253 /* Specified name of aux-info file.  */
254
255 const char *aux_info_file_name;
256
257 /* Nonzero if we are compiling code for a shared library, zero for
258    executable.  */
259
260 int flag_shlib;
261
262 /* Generate code for GNU or NeXT Objective-C runtime environment.  */
263
264 #ifdef NEXT_OBJC_RUNTIME
265 int flag_next_runtime = 1;
266 #else
267 int flag_next_runtime = 0;
268 #endif
269
270 /* Set to the default thread-local storage (tls) model to use.  */
271
272 enum tls_model flag_tls_default = TLS_MODEL_GLOBAL_DYNAMIC;
273
274 /* Set the default algorithm for the integrated register allocator.  */
275
276 enum ira_algorithm flag_ira_algorithm = IRA_ALGORITHM_MIXED;
277
278 /* Set the default value for -fira-verbose.  */
279
280 unsigned int flag_ira_verbose = 5;
281
282 /* Nonzero means change certain warnings into errors.
283    Usually these are warnings about failure to conform to some standard.  */
284
285 int flag_pedantic_errors = 0;
286
287 /* Nonzero means make permerror produce warnings instead of errors.  */
288
289 int flag_permissive = 0;
290
291 /* -dA causes debug commentary information to be produced in
292    the generated assembly code (to make it more readable).  This option
293    is generally only of use to those who actually need to read the
294    generated assembly code (perhaps while debugging the compiler itself).
295    Currently, this switch is only used by dwarfout.c; however, it is intended
296    to be a catchall for printing debug information in the assembler file.  */
297
298 int flag_debug_asm = 0;
299
300 /* -dP causes the rtl to be emitted as a comment in assembly.  */
301
302 int flag_dump_rtl_in_asm = 0;
303
304 /* When non-NULL, indicates that whenever space is allocated on the
305    stack, the resulting stack pointer must not pass this
306    address---that is, for stacks that grow downward, the stack pointer
307    must always be greater than or equal to this address; for stacks
308    that grow upward, the stack pointer must be less than this address.
309    At present, the rtx may be either a REG or a SYMBOL_REF, although
310    the support provided depends on the backend.  */
311 rtx stack_limit_rtx;
312
313 /* Nonzero if we should track variables.  When
314    flag_var_tracking == AUTODETECT_VALUE it will be set according
315    to optimize, debug_info_level and debug_hooks in process_options ().  */
316 int flag_var_tracking = AUTODETECT_VALUE;
317
318 /* Type of stack check.  */
319 enum stack_check_type flag_stack_check = NO_STACK_CHECK;
320
321 /* True if the user has tagged the function with the 'section'
322    attribute.  */
323
324 bool user_defined_section_attribute = false;
325
326 /* Values of the -falign-* flags: how much to align labels in code.
327    0 means `use default', 1 means `don't align'.
328    For each variable, there is an _log variant which is the power
329    of two not less than the variable, for .align output.  */
330
331 int align_loops_log;
332 int align_loops_max_skip;
333 int align_jumps_log;
334 int align_jumps_max_skip;
335 int align_labels_log;
336 int align_labels_max_skip;
337 int align_functions_log;
338
339 typedef struct
340 {
341   const char *const string;
342   int *const variable;
343   const int on_value;
344 }
345 lang_independent_options;
346
347 /* Nonzero if subexpressions must be evaluated from left-to-right.  */
348 int flag_evaluation_order = 0;
349
350 /* The user symbol prefix after having resolved same.  */
351 const char *user_label_prefix;
352
353 static const param_info lang_independent_params[] = {
354 #define DEFPARAM(ENUM, OPTION, HELP, DEFAULT, MIN, MAX) \
355   { OPTION, DEFAULT, false, MIN, MAX, HELP },
356 #include "params.def"
357 #undef DEFPARAM
358   { NULL, 0, false, 0, 0, NULL }
359 };
360
361 /* Output files for assembler code (real compiler output)
362    and debugging dumps.  */
363
364 FILE *asm_out_file;
365 FILE *aux_info_file;
366 FILE *dump_file = NULL;
367 const char *dump_file_name;
368
369 /* The current working directory of a translation.  It's generally the
370    directory from which compilation was initiated, but a preprocessed
371    file may specify the original directory in which it was
372    created.  */
373
374 static const char *src_pwd;
375
376 /* Initialize src_pwd with the given string, and return true.  If it
377    was already initialized, return false.  As a special case, it may
378    be called with a NULL argument to test whether src_pwd has NOT been
379    initialized yet.  */
380
381 bool
382 set_src_pwd (const char *pwd)
383 {
384   if (src_pwd)
385     {
386       if (strcmp (src_pwd, pwd) == 0)
387         return true;
388       else
389         return false;
390     }
391
392   src_pwd = xstrdup (pwd);
393   return true;
394 }
395
396 /* Return the directory from which the translation unit was initiated,
397    in case set_src_pwd() was not called before to assign it a
398    different value.  */
399
400 const char *
401 get_src_pwd (void)
402 {
403   if (! src_pwd)
404     {
405       src_pwd = getpwd ();
406       if (!src_pwd)
407         src_pwd = ".";
408     }
409
410    return src_pwd;
411 }
412
413 /* Called when the start of a function definition is parsed,
414    this function prints on stderr the name of the function.  */
415 void
416 announce_function (tree decl)
417 {
418   if (!quiet_flag)
419     {
420       if (rtl_dump_and_exit)
421         fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
422       else
423         fprintf (stderr, " %s", lang_hooks.decl_printable_name (decl, 2));
424       fflush (stderr);
425       pp_needs_newline (global_dc->printer) = true;
426       diagnostic_set_last_function (global_dc, (diagnostic_info *) NULL);
427     }
428 }
429
430 /* Initialize local_tick with the time of day, or -1 if
431    flag_random_seed is set.  */
432
433 static void
434 init_local_tick (void)
435 {
436   if (!flag_random_seed)
437     {
438       /* Get some more or less random data.  */
439 #ifdef HAVE_GETTIMEOFDAY
440       {
441         struct timeval tv;
442
443         gettimeofday (&tv, NULL);
444         local_tick = tv.tv_sec * 1000 + tv.tv_usec / 1000;
445       }
446 #else
447       {
448         time_t now = time (NULL);
449
450         if (now != (time_t)-1)
451           local_tick = (unsigned) now;
452       }
453 #endif
454     }
455   else
456     local_tick = -1;
457 }
458
459 /* Set up a default flag_random_seed and local_tick, unless the user
460    already specified one.  Must be called after init_local_tick.  */
461
462 static void
463 init_random_seed (void)
464 {
465   unsigned HOST_WIDE_INT value;
466   static char random_seed[HOST_BITS_PER_WIDE_INT / 4 + 3];
467
468   value = local_tick ^ getpid ();
469
470   sprintf (random_seed, HOST_WIDE_INT_PRINT_HEX, value);
471   flag_random_seed = random_seed;
472 }
473
474 /* Obtain the random_seed string.  Unless NOINIT, initialize it if
475    it's not provided in the command line.  */
476
477 const char *
478 get_random_seed (bool noinit)
479 {
480   if (!flag_random_seed && !noinit)
481     init_random_seed ();
482   return flag_random_seed;
483 }
484
485 /* Modify the random_seed string to VAL.  Return its previous
486    value.  */
487
488 const char *
489 set_random_seed (const char *val)
490 {
491   const char *old = flag_random_seed;
492   flag_random_seed = val;
493   return old;
494 }
495
496 /* Decode the string P as an integral parameter.
497    If the string is indeed an integer return its numeric value else
498    issue an Invalid Option error for the option PNAME and return DEFVAL.
499    If PNAME is zero just return DEFVAL, do not call error.  */
500
501 int
502 read_integral_parameter (const char *p, const char *pname, const int  defval)
503 {
504   const char *endp = p;
505
506   while (*endp)
507     {
508       if (ISDIGIT (*endp))
509         endp++;
510       else
511         break;
512     }
513
514   if (*endp != 0)
515     {
516       if (pname != 0)
517         error ("invalid option argument %qs", pname);
518       return defval;
519     }
520
521   return atoi (p);
522 }
523
524 /* When compiling with a recent enough GCC, we use the GNU C "extern inline"
525    for floor_log2 and exact_log2; see toplev.h.  That construct, however,
526    conflicts with the ISO C++ One Definition Rule.   */
527
528 #if GCC_VERSION < 3004 || !defined (__cplusplus)
529
530 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
531    If X is 0, return -1.  */
532
533 int
534 floor_log2 (unsigned HOST_WIDE_INT x)
535 {
536   int t = 0;
537
538   if (x == 0)
539     return -1;
540
541 #ifdef CLZ_HWI
542   t = HOST_BITS_PER_WIDE_INT - 1 - (int) CLZ_HWI (x);
543 #else
544   if (HOST_BITS_PER_WIDE_INT > 64)
545     if (x >= (unsigned HOST_WIDE_INT) 1 << (t + 64))
546       t += 64;
547   if (HOST_BITS_PER_WIDE_INT > 32)
548     if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 32))
549       t += 32;
550   if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 16))
551     t += 16;
552   if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 8))
553     t += 8;
554   if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 4))
555     t += 4;
556   if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 2))
557     t += 2;
558   if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 1))
559     t += 1;
560 #endif
561
562   return t;
563 }
564
565 /* Return the logarithm of X, base 2, considering X unsigned,
566    if X is a power of 2.  Otherwise, returns -1.  */
567
568 int
569 exact_log2 (unsigned HOST_WIDE_INT x)
570 {
571   if (x != (x & -x))
572     return -1;
573 #ifdef CTZ_HWI
574   return x ? CTZ_HWI (x) : -1;
575 #else
576   return floor_log2 (x);
577 #endif
578 }
579
580 #endif /*  GCC_VERSION < 3004 || !defined (__cplusplus)  */
581
582 /* Handler for fatal signals, such as SIGSEGV.  These are transformed
583    into ICE messages, which is much more user friendly.  In case the
584    error printer crashes, reset the signal to prevent infinite recursion.  */
585
586 static void
587 crash_signal (int signo)
588 {
589   signal (signo, SIG_DFL);
590
591   /* If we crashed while processing an ASM statement, then be a little more
592      graceful.  It's most likely the user's fault.  */
593   if (this_is_asm_operands)
594     {
595       output_operand_lossage ("unrecoverable error");
596       exit (FATAL_EXIT_CODE);
597     }
598
599   internal_error ("%s", strsignal (signo));
600 }
601
602 /* Arrange to dump core on error.  (The regular error message is still
603    printed first, except in the case of abort().)  */
604
605 static void
606 setup_core_dumping (void)
607 {
608 #ifdef SIGABRT
609   signal (SIGABRT, SIG_DFL);
610 #endif
611 #if defined(HAVE_SETRLIMIT)
612   {
613     struct rlimit rlim;
614     if (getrlimit (RLIMIT_CORE, &rlim) != 0)
615       fatal_error ("getting core file size maximum limit: %m");
616     rlim.rlim_cur = rlim.rlim_max;
617     if (setrlimit (RLIMIT_CORE, &rlim) != 0)
618       fatal_error ("setting core file size limit to maximum: %m");
619   }
620 #endif
621   diagnostic_abort_on_error (global_dc);
622 }
623
624
625 /* Strip off a legitimate source ending from the input string NAME of
626    length LEN.  Rather than having to know the names used by all of
627    our front ends, we strip off an ending of a period followed by
628    up to five characters.  (Java uses ".class".)  */
629
630 void
631 strip_off_ending (char *name, int len)
632 {
633   int i;
634   for (i = 2; i < 6 && len > i; i++)
635     {
636       if (name[len - i] == '.')
637         {
638           name[len - i] = '\0';
639           break;
640         }
641     }
642 }
643
644 /* Output a quoted string.  */
645
646 void
647 output_quoted_string (FILE *asm_file, const char *string)
648 {
649 #ifdef OUTPUT_QUOTED_STRING
650   OUTPUT_QUOTED_STRING (asm_file, string);
651 #else
652   char c;
653
654   putc ('\"', asm_file);
655   while ((c = *string++) != 0)
656     {
657       if (ISPRINT (c))
658         {
659           if (c == '\"' || c == '\\')
660             putc ('\\', asm_file);
661           putc (c, asm_file);
662         }
663       else
664         fprintf (asm_file, "\\%03o", (unsigned char) c);
665     }
666   putc ('\"', asm_file);
667 #endif
668 }
669
670 /* Output a file name in the form wanted by System V.  */
671
672 void
673 output_file_directive (FILE *asm_file, const char *input_name)
674 {
675   int len;
676   const char *na;
677
678   if (input_name == NULL)
679     input_name = "<stdin>";
680   else
681     input_name = remap_debug_filename (input_name);
682
683   len = strlen (input_name);
684   na = input_name + len;
685
686   /* NA gets INPUT_NAME sans directory names.  */
687   while (na > input_name)
688     {
689       if (IS_DIR_SEPARATOR (na[-1]))
690         break;
691       na--;
692     }
693
694 #ifdef ASM_OUTPUT_SOURCE_FILENAME
695   ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
696 #else
697   fprintf (asm_file, "\t.file\t");
698   output_quoted_string (asm_file, na);
699   fputc ('\n', asm_file);
700 #endif
701 }
702
703 /* A subroutine of wrapup_global_declarations.  We've come to the end of
704    the compilation unit.  All deferred variables should be undeferred,
705    and all incomplete decls should be finalized.  */
706
707 void
708 wrapup_global_declaration_1 (tree decl)
709 {
710   /* We're not deferring this any longer.  Assignment is conditional to
711      avoid needlessly dirtying PCH pages.  */
712   if (CODE_CONTAINS_STRUCT (TREE_CODE (decl), TS_DECL_WITH_VIS)
713       && DECL_DEFER_OUTPUT (decl) != 0)
714     DECL_DEFER_OUTPUT (decl) = 0;
715
716   if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0)
717     lang_hooks.finish_incomplete_decl (decl);
718 }
719
720 /* A subroutine of wrapup_global_declarations.  Decide whether or not DECL
721    needs to be output.  Return true if it is output.  */
722
723 bool
724 wrapup_global_declaration_2 (tree decl)
725 {
726   if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
727     return false;
728
729   /* Don't write out static consts, unless we still need them.
730
731      We also keep static consts if not optimizing (for debugging),
732      unless the user specified -fno-keep-static-consts.
733      ??? They might be better written into the debug information.
734      This is possible when using DWARF.
735
736      A language processor that wants static constants to be always
737      written out (even if it is not used) is responsible for
738      calling rest_of_decl_compilation itself.  E.g. the C front-end
739      calls rest_of_decl_compilation from finish_decl.
740      One motivation for this is that is conventional in some
741      environments to write things like:
742      static const char rcsid[] = "... version string ...";
743      intending to force the string to be in the executable.
744
745      A language processor that would prefer to have unneeded
746      static constants "optimized away" would just defer writing
747      them out until here.  E.g. C++ does this, because static
748      constants are often defined in header files.
749
750      ??? A tempting alternative (for both C and C++) would be
751      to force a constant to be written if and only if it is
752      defined in a main file, as opposed to an include file.  */
753
754   if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl))
755     {
756       struct varpool_node *node;
757       bool needed = true;
758       node = varpool_node (decl);
759
760       if (node->finalized)
761         needed = false;
762       else if (node->alias)
763         needed = false;
764       else if (!cgraph_global_info_ready
765                && (TREE_USED (decl)
766                    || TREE_USED (DECL_ASSEMBLER_NAME (decl))))
767         /* needed */;
768       else if (node->needed)
769         /* needed */;
770       else if (DECL_COMDAT (decl))
771         needed = false;
772       else if (TREE_READONLY (decl) && !TREE_PUBLIC (decl)
773                && (optimize || !flag_keep_static_consts
774                    || DECL_ARTIFICIAL (decl)))
775         needed = false;
776
777       if (needed)
778         {
779           rest_of_decl_compilation (decl, 1, 1);
780           return true;
781         }
782     }
783
784   return false;
785 }
786
787 /* Do any final processing required for the declarations in VEC, of
788    which there are LEN.  We write out inline functions and variables
789    that have been deferred until this point, but which are required.
790    Returns nonzero if anything was put out.  */
791
792 bool
793 wrapup_global_declarations (tree *vec, int len)
794 {
795   bool reconsider, output_something = false;
796   int i;
797
798   for (i = 0; i < len; i++)
799     wrapup_global_declaration_1 (vec[i]);
800
801   /* Now emit any global variables or functions that we have been
802      putting off.  We need to loop in case one of the things emitted
803      here references another one which comes earlier in the list.  */
804   do
805     {
806       reconsider = false;
807       for (i = 0; i < len; i++)
808         reconsider |= wrapup_global_declaration_2 (vec[i]);
809       if (reconsider)
810         output_something = true;
811     }
812   while (reconsider);
813
814   return output_something;
815 }
816
817 /* A subroutine of check_global_declarations.  Issue appropriate warnings
818    for the global declaration DECL.  */
819
820 void
821 check_global_declaration_1 (tree decl)
822 {
823   /* Warn about any function declared static but not defined.  We don't
824      warn about variables, because many programs have static variables
825      that exist only to get some text into the object file.  */
826   if (TREE_CODE (decl) == FUNCTION_DECL
827       && DECL_INITIAL (decl) == 0
828       && DECL_EXTERNAL (decl)
829       && ! DECL_ARTIFICIAL (decl)
830       && ! TREE_NO_WARNING (decl)
831       && ! TREE_PUBLIC (decl)
832       && (warn_unused_function
833           || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
834     {
835       if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
836         pedwarn (input_location, 0, "%q+F used but never defined", decl);
837       else
838         warning (OPT_Wunused_function, "%q+F declared %<static%> but never defined", decl);
839       /* This symbol is effectively an "extern" declaration now.  */
840       TREE_PUBLIC (decl) = 1;
841       assemble_external (decl);
842     }
843
844   /* Warn about static fns or vars defined but not used.  */
845   if (((warn_unused_function && TREE_CODE (decl) == FUNCTION_DECL)
846        /* We don't warn about "static const" variables because the
847           "rcs_id" idiom uses that construction.  */
848        || (warn_unused_variable
849            && TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
850       && ! DECL_IN_SYSTEM_HEADER (decl)
851       && ! TREE_USED (decl)
852       /* The TREE_USED bit for file-scope decls is kept in the identifier,
853          to handle multiple external decls in different scopes.  */
854       && ! (DECL_NAME (decl) && TREE_USED (DECL_NAME (decl)))
855       && ! DECL_EXTERNAL (decl)
856       && ! TREE_PUBLIC (decl)
857       /* A volatile variable might be used in some non-obvious way.  */
858       && ! TREE_THIS_VOLATILE (decl)
859       /* Global register variables must be declared to reserve them.  */
860       && ! (TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl))
861       /* Otherwise, ask the language.  */
862       && lang_hooks.decls.warn_unused_global (decl))
863     warning ((TREE_CODE (decl) == FUNCTION_DECL) 
864              ? OPT_Wunused_function 
865              : OPT_Wunused_variable, 
866              "%q+D defined but not used", decl);
867 }
868
869 /* Issue appropriate warnings for the global declarations in VEC (of
870    which there are LEN).  */
871
872 void
873 check_global_declarations (tree *vec, int len)
874 {
875   int i;
876
877   for (i = 0; i < len; i++)
878     check_global_declaration_1 (vec[i]);
879 }
880
881 /* Emit debugging information for all global declarations in VEC.  */
882
883 void
884 emit_debug_global_declarations (tree *vec, int len)
885 {
886   int i;
887
888   /* Avoid confusing the debug information machinery when there are errors.  */
889   if (errorcount != 0 || sorrycount != 0)
890     return;
891
892   timevar_push (TV_SYMOUT);
893   for (i = 0; i < len; i++)
894     debug_hooks->global_decl (vec[i]);
895   timevar_pop (TV_SYMOUT);
896 }
897
898 /* Warn about a use of an identifier which was marked deprecated.  */
899 void
900 warn_deprecated_use (tree node)
901 {
902   if (node == 0 || !warn_deprecated_decl)
903     return;
904
905   if (DECL_P (node))
906     {
907       expanded_location xloc = expand_location (DECL_SOURCE_LOCATION (node));
908       warning (OPT_Wdeprecated_declarations,
909                "%qD is deprecated (declared at %s:%d)",
910                node, xloc.file, xloc.line);
911     }
912   else if (TYPE_P (node))
913     {
914       const char *what = NULL;
915       tree decl = TYPE_STUB_DECL (node);
916
917       if (TYPE_NAME (node))
918         {
919           if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
920             what = IDENTIFIER_POINTER (TYPE_NAME (node));
921           else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
922                    && DECL_NAME (TYPE_NAME (node)))
923             what = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node)));
924         }
925
926       if (decl)
927         {
928           expanded_location xloc
929             = expand_location (DECL_SOURCE_LOCATION (decl));
930           if (what)
931             warning (OPT_Wdeprecated_declarations,
932                      "%qs is deprecated (declared at %s:%d)", what,
933                      xloc.file, xloc.line);
934           else
935             warning (OPT_Wdeprecated_declarations,
936                      "type is deprecated (declared at %s:%d)",
937                      xloc.file, xloc.line);
938         }
939       else
940         {
941           if (what)
942             warning (OPT_Wdeprecated_declarations, "%qs is deprecated", what);
943           else
944             warning (OPT_Wdeprecated_declarations, "type is deprecated");
945         }
946     }
947 }
948
949 /* Compile an entire translation unit.  Write a file of assembly
950    output and various debugging dumps.  */
951
952 static void
953 compile_file (void)
954 {
955   /* Initialize yet another pass.  */
956
957   ggc_protect_identifiers = true;
958
959   init_cgraph ();
960   init_final (main_input_filename);
961   coverage_init (aux_base_name);
962   statistics_init ();
963
964   timevar_push (TV_PARSE);
965
966   /* Call the parser, which parses the entire file (calling
967      rest_of_compilation for each function).  */
968   lang_hooks.parse_file (set_yydebug);
969
970   /* Compilation is now finished except for writing
971      what's left of the symbol table output.  */
972   timevar_pop (TV_PARSE);
973
974   if (flag_syntax_only)
975     return;
976
977   ggc_protect_identifiers = false;
978
979   lang_hooks.decls.final_write_globals ();
980
981   if (errorcount || sorrycount)
982     return;
983
984   varpool_assemble_pending_decls ();
985   finish_aliases_2 ();
986
987   /* This must occur after the loop to output deferred functions.
988      Else the coverage initializer would not be emitted if all the
989      functions in this compilation unit were deferred.  */
990   coverage_finish ();
991
992   /* Likewise for mudflap static object registrations.  */
993   if (flag_mudflap)
994     mudflap_finish_file ();
995
996   /* Likewise for emulated thread-local storage.  */
997   if (!targetm.have_tls)
998     emutls_finish ();
999
1000   output_shared_constant_pool ();
1001   output_object_blocks ();
1002
1003   /* Write out any pending weak symbol declarations.  */
1004   weak_finish ();
1005
1006   /* Do dbx symbols.  */
1007   timevar_push (TV_SYMOUT);
1008
1009 #if defined DWARF2_DEBUGGING_INFO || defined DWARF2_UNWIND_INFO
1010   if (dwarf2out_do_frame ())
1011     dwarf2out_frame_finish ();
1012 #endif
1013
1014   (*debug_hooks->finish) (main_input_filename);
1015   timevar_pop (TV_SYMOUT);
1016
1017   /* Output some stuff at end of file if nec.  */
1018
1019   dw2_output_indirect_constants ();
1020
1021   /* Flush any pending external directives.  */
1022   process_pending_assemble_externals ();
1023
1024   /* Attach a special .ident directive to the end of the file to identify
1025      the version of GCC which compiled this code.  The format of the .ident
1026      string is patterned after the ones produced by native SVR4 compilers.  */
1027 #ifdef IDENT_ASM_OP
1028   if (!flag_no_ident)
1029     {
1030       const char *pkg_version = "(GNU) ";
1031
1032       if (strcmp ("(GCC) ", pkgversion_string))
1033         pkg_version = pkgversion_string;
1034       fprintf (asm_out_file, "%s\"GCC: %s%s\"\n",
1035                IDENT_ASM_OP, pkg_version, version_string);
1036     }
1037 #endif
1038
1039   /* This must be at the end.  Some target ports emit end of file directives
1040      into the assembly file here, and hence we can not output anything to the
1041      assembly file after this point.  */
1042   targetm.asm_out.file_end ();
1043 }
1044
1045 /* Parse a -d... command line switch.  */
1046
1047 void
1048 decode_d_option (const char *arg)
1049 {
1050   int c;
1051
1052   while (*arg)
1053     switch (c = *arg++)
1054       {
1055       case 'A':
1056         flag_debug_asm = 1;
1057         break;
1058       case 'p':
1059         flag_print_asm_name = 1;
1060         break;
1061       case 'P':
1062         flag_dump_rtl_in_asm = 1;
1063         flag_print_asm_name = 1;
1064         break;
1065       case 'v':
1066         graph_dump_format = vcg;
1067         break;
1068       case 'x':
1069         rtl_dump_and_exit = 1;
1070         break;
1071       case 'y':
1072         set_yydebug = 1;
1073         break;
1074       case 'D': /* These are handled by the preprocessor.  */
1075       case 'I':
1076       case 'M':
1077       case 'N':
1078       case 'U':
1079         break;
1080       case 'H':
1081         setup_core_dumping();
1082         break;
1083       case 'a':
1084         enable_rtl_dump_file ();
1085         break;
1086
1087       default:
1088           warning (0, "unrecognized gcc debugging option: %c", c);
1089         break;
1090       }
1091 }
1092
1093 /* Indexed by enum debug_info_type.  */
1094 const char *const debug_type_names[] =
1095 {
1096   "none", "stabs", "coff", "dwarf-2", "xcoff", "vms"
1097 };
1098
1099 /* Print version information to FILE.
1100    Each line begins with INDENT (for the case where FILE is the
1101    assembler output file).  */
1102
1103 void
1104 print_version (FILE *file, const char *indent)
1105 {
1106   static const char fmt1[] =
1107 #ifdef __GNUC__
1108     N_("%s%s%s %sversion %s (%s)\n%s\tcompiled by GNU C version %s, ")
1109 #else
1110     N_("%s%s%s %sversion %s (%s) compiled by CC, ")
1111 #endif
1112     ;
1113   static const char fmt2[] =
1114     N_("GMP version %s, MPFR version %s.\n");
1115   static const char fmt3[] =
1116     N_("%s%swarning: %s header version %s differs from library version %s.\n");
1117   static const char fmt4[] =
1118     N_("%s%sGGC heuristics: --param ggc-min-expand=%d --param ggc-min-heapsize=%d\n");
1119 #ifndef __VERSION__
1120 #define __VERSION__ "[?]"
1121 #endif
1122   fprintf (file,
1123            file == stderr ? _(fmt1) : fmt1,
1124            indent, *indent != 0 ? " " : "",
1125            lang_hooks.name, pkgversion_string, version_string, TARGET_NAME,
1126            indent, __VERSION__);
1127
1128   /* We need to stringify the GMP macro values.  Ugh, gmp_version has
1129      two string formats, "i.j.k" and "i.j" when k is zero.  */
1130 #define GCC_GMP_STRINGIFY_VERSION3(X) #X
1131 #define GCC_GMP_STRINGIFY_VERSION2(X) GCC_GMP_STRINGIFY_VERSION3(X)
1132 #if __GNU_MP_VERSION_PATCHLEVEL == 0
1133 #define GCC_GMP_STRINGIFY_VERSION GCC_GMP_STRINGIFY_VERSION2(__GNU_MP_VERSION) "." \
1134   GCC_GMP_STRINGIFY_VERSION2(__GNU_MP_VERSION_MINOR)
1135 #else
1136 #define GCC_GMP_STRINGIFY_VERSION GCC_GMP_STRINGIFY_VERSION2(__GNU_MP_VERSION) "." \
1137   GCC_GMP_STRINGIFY_VERSION2(__GNU_MP_VERSION_MINOR) "." \
1138   GCC_GMP_STRINGIFY_VERSION2(__GNU_MP_VERSION_PATCHLEVEL)
1139 #endif
1140   fprintf (file,
1141            file == stderr ? _(fmt2) : fmt2,
1142            GCC_GMP_STRINGIFY_VERSION, MPFR_VERSION_STRING);
1143   if (strcmp (GCC_GMP_STRINGIFY_VERSION, gmp_version))
1144     fprintf (file,
1145              file == stderr ? _(fmt3) : fmt3,
1146              indent, *indent != 0 ? " " : "",
1147              "GMP", GCC_GMP_STRINGIFY_VERSION, gmp_version);
1148   if (strcmp (MPFR_VERSION_STRING, mpfr_get_version ()))
1149     fprintf (file,
1150              file == stderr ? _(fmt3) : fmt3,
1151              indent, *indent != 0 ? " " : "",
1152              "MPFR", MPFR_VERSION_STRING, mpfr_get_version ());
1153   fprintf (file,
1154            file == stderr ? _(fmt4) : fmt4,
1155            indent, *indent != 0 ? " " : "",
1156            PARAM_VALUE (GGC_MIN_EXPAND), PARAM_VALUE (GGC_MIN_HEAPSIZE));
1157 }
1158
1159 #ifdef ASM_COMMENT_START
1160 static int
1161 print_to_asm_out_file (print_switch_type type, const char * text)
1162 {
1163   bool prepend_sep = true;
1164
1165   switch (type)
1166     {
1167     case SWITCH_TYPE_LINE_END:
1168       putc ('\n', asm_out_file);
1169       return 1;
1170
1171     case SWITCH_TYPE_LINE_START:
1172       fputs (ASM_COMMENT_START, asm_out_file);
1173       return strlen (ASM_COMMENT_START);
1174
1175     case SWITCH_TYPE_DESCRIPTIVE:
1176       if (ASM_COMMENT_START[0] == 0)
1177         prepend_sep = false;
1178       /* Drop through.  */
1179     case SWITCH_TYPE_PASSED:
1180     case SWITCH_TYPE_ENABLED:
1181       if (prepend_sep)
1182         fputc (' ', asm_out_file);
1183       fprintf (asm_out_file, text);
1184       /* No need to return the length here as
1185          print_single_switch has already done it.  */
1186       return 0;
1187
1188     default:
1189       return -1;
1190     }
1191 }
1192 #endif
1193
1194 static int
1195 print_to_stderr (print_switch_type type, const char * text)
1196 {
1197   switch (type)
1198     {
1199     case SWITCH_TYPE_LINE_END:
1200       putc ('\n', stderr);
1201       return 1;
1202
1203     case SWITCH_TYPE_LINE_START:
1204       return 0;
1205       
1206     case SWITCH_TYPE_PASSED:
1207     case SWITCH_TYPE_ENABLED:
1208       fputc (' ', stderr);
1209       /* Drop through.  */
1210
1211     case SWITCH_TYPE_DESCRIPTIVE:
1212       fprintf (stderr, text);
1213       /* No need to return the length here as
1214          print_single_switch has already done it.  */
1215       return 0;
1216
1217     default:
1218       return -1;
1219     }
1220 }
1221
1222 /* Print an option value and return the adjusted position in the line.
1223    ??? print_fn doesn't handle errors, eg disk full; presumably other
1224    code will catch a disk full though.  */
1225
1226 static int
1227 print_single_switch (print_switch_fn_type print_fn,
1228                      int pos,
1229                      print_switch_type type,
1230                      const char * text)
1231 {
1232   /* The ultrix fprintf returns 0 on success, so compute the result
1233      we want here since we need it for the following test.  The +1
1234      is for the separator character that will probably be emitted.  */
1235   int len = strlen (text) + 1;
1236
1237   if (pos != 0
1238       && pos + len > MAX_LINE)
1239     {
1240       print_fn (SWITCH_TYPE_LINE_END, NULL);
1241       pos = 0;
1242     }
1243
1244   if (pos == 0)
1245     pos += print_fn (SWITCH_TYPE_LINE_START, NULL);
1246
1247   print_fn (type, text);
1248   return pos + len;
1249 }
1250
1251 /* Print active target switches using PRINT_FN.
1252    POS is the current cursor position and MAX is the size of a "line".
1253    Each line begins with INDENT and ends with TERM.
1254    Each switch is separated from the next by SEP.  */
1255
1256 static void
1257 print_switch_values (print_switch_fn_type print_fn)
1258 {
1259   int pos = 0;
1260   size_t j;
1261   const char **p;
1262
1263   /* Fill in the -frandom-seed option, if the user didn't pass it, so
1264      that it can be printed below.  This helps reproducibility.  */
1265   if (!flag_random_seed)
1266     init_random_seed ();
1267
1268   /* Print the options as passed.  */
1269   pos = print_single_switch (print_fn, pos,
1270                              SWITCH_TYPE_DESCRIPTIVE, _("options passed: "));
1271
1272   for (p = &save_argv[1]; *p != NULL; p++)
1273     {
1274       if (**p == '-')
1275         {
1276           /* Ignore these.  */
1277           if (strcmp (*p, "-o") == 0
1278               || strcmp (*p, "-dumpbase") == 0
1279               || strcmp (*p, "-auxbase") == 0)
1280             {
1281               if (p[1] != NULL)
1282                 p++;
1283               continue;
1284             }
1285
1286           if (strcmp (*p, "-quiet") == 0
1287               || strcmp (*p, "-version") == 0)
1288             continue;
1289
1290           if ((*p)[1] == 'd')
1291             continue;
1292         }
1293
1294       pos = print_single_switch (print_fn, pos, SWITCH_TYPE_PASSED, *p);
1295     }
1296
1297   if (pos > 0)
1298     print_fn (SWITCH_TYPE_LINE_END, NULL);
1299
1300   /* Print the -f and -m options that have been enabled.
1301      We don't handle language specific options but printing argv
1302      should suffice.  */
1303   pos = print_single_switch (print_fn, 0,
1304                              SWITCH_TYPE_DESCRIPTIVE, _("options enabled: "));
1305
1306   for (j = 0; j < cl_options_count; j++)
1307     if ((cl_options[j].flags & CL_REPORT)
1308         && option_enabled (j) > 0)
1309       pos = print_single_switch (print_fn, pos,
1310                                  SWITCH_TYPE_ENABLED, cl_options[j].opt_text);
1311
1312   print_fn (SWITCH_TYPE_LINE_END, NULL);
1313 }
1314
1315 /* Open assembly code output file.  Do this even if -fsyntax-only is
1316    on, because then the driver will have provided the name of a
1317    temporary file or bit bucket for us.  NAME is the file specified on
1318    the command line, possibly NULL.  */
1319 static void
1320 init_asm_output (const char *name)
1321 {
1322   if (name == NULL && asm_file_name == 0)
1323     asm_out_file = stdout;
1324   else
1325     {
1326       if (asm_file_name == 0)
1327         {
1328           int len = strlen (dump_base_name);
1329           char *dumpname = XNEWVEC (char, len + 6);
1330
1331           memcpy (dumpname, dump_base_name, len + 1);
1332           strip_off_ending (dumpname, len);
1333           strcat (dumpname, ".s");
1334           asm_file_name = dumpname;
1335         }
1336       if (!strcmp (asm_file_name, "-"))
1337         asm_out_file = stdout;
1338       else
1339         asm_out_file = fopen (asm_file_name, "w+b");
1340       if (asm_out_file == 0)
1341         fatal_error ("can%'t open %s for writing: %m", asm_file_name);
1342     }
1343
1344   if (!flag_syntax_only)
1345     {
1346       targetm.asm_out.file_start ();
1347
1348       if (flag_record_gcc_switches)
1349         {
1350           if (targetm.asm_out.record_gcc_switches)
1351             {
1352               /* Let the target know that we are about to start recording.  */
1353               targetm.asm_out.record_gcc_switches (SWITCH_TYPE_DESCRIPTIVE,
1354                                                    NULL);
1355               /* Now record the switches.  */
1356               print_switch_values (targetm.asm_out.record_gcc_switches);
1357               /* Let the target know that the recording is over.  */
1358               targetm.asm_out.record_gcc_switches (SWITCH_TYPE_DESCRIPTIVE,
1359                                                    NULL);
1360             }
1361           else
1362             inform (input_location, "-frecord-gcc-switches is not supported by the current target");
1363         }
1364
1365 #ifdef ASM_COMMENT_START
1366       if (flag_verbose_asm)
1367         {
1368           /* Print the list of switches in effect
1369              into the assembler file as comments.  */
1370           print_version (asm_out_file, ASM_COMMENT_START);
1371           print_switch_values (print_to_asm_out_file);
1372           fprintf (asm_out_file, "\n");
1373         }
1374 #endif
1375     }
1376 }
1377
1378 /* Return true if the state of option OPTION should be stored in PCH files
1379    and checked by default_pch_valid_p.  Store the option's current state
1380    in STATE if so.  */
1381
1382 static inline bool
1383 option_affects_pch_p (int option, struct cl_option_state *state)
1384 {
1385   if ((cl_options[option].flags & CL_TARGET) == 0)
1386     return false;
1387   if (cl_options[option].flag_var == &target_flags)
1388     if (targetm.check_pch_target_flags)
1389       return false;
1390   return get_option_state (option, state);
1391 }
1392
1393 /* Default version of get_pch_validity.
1394    By default, every flag difference is fatal; that will be mostly right for
1395    most targets, but completely right for very few.  */
1396
1397 void *
1398 default_get_pch_validity (size_t *len)
1399 {
1400   struct cl_option_state state;
1401   size_t i;
1402   char *result, *r;
1403
1404   *len = 2;
1405   if (targetm.check_pch_target_flags)
1406     *len += sizeof (target_flags);
1407   for (i = 0; i < cl_options_count; i++)
1408     if (option_affects_pch_p (i, &state))
1409       *len += state.size;
1410
1411   result = r = XNEWVEC (char, *len);
1412   r[0] = flag_pic;
1413   r[1] = flag_pie;
1414   r += 2;
1415   if (targetm.check_pch_target_flags)
1416     {
1417       memcpy (r, &target_flags, sizeof (target_flags));
1418       r += sizeof (target_flags);
1419     }
1420
1421   for (i = 0; i < cl_options_count; i++)
1422     if (option_affects_pch_p (i, &state))
1423       {
1424         memcpy (r, state.data, state.size);
1425         r += state.size;
1426       }
1427
1428   return result;
1429 }
1430
1431 /* Return a message which says that a PCH file was created with a different
1432    setting of OPTION.  */
1433
1434 static const char *
1435 pch_option_mismatch (const char *option)
1436 {
1437   char *r;
1438
1439   asprintf (&r, _("created and used with differing settings of '%s'"), option);
1440   if (r == NULL)
1441     return _("out of memory");
1442   return r;
1443 }
1444
1445 /* Default version of pch_valid_p.  */
1446
1447 const char *
1448 default_pch_valid_p (const void *data_p, size_t len)
1449 {
1450   struct cl_option_state state;
1451   const char *data = (const char *)data_p;
1452   size_t i;
1453
1454   /* -fpic and -fpie also usually make a PCH invalid.  */
1455   if (data[0] != flag_pic)
1456     return _("created and used with different settings of -fpic");
1457   if (data[1] != flag_pie)
1458     return _("created and used with different settings of -fpie");
1459   data += 2;
1460
1461   /* Check target_flags.  */
1462   if (targetm.check_pch_target_flags)
1463     {
1464       int tf;
1465       const char *r;
1466
1467       memcpy (&tf, data, sizeof (target_flags));
1468       data += sizeof (target_flags);
1469       len -= sizeof (target_flags);
1470       r = targetm.check_pch_target_flags (tf);
1471       if (r != NULL)
1472         return r;
1473     }
1474
1475   for (i = 0; i < cl_options_count; i++)
1476     if (option_affects_pch_p (i, &state))
1477       {
1478         if (memcmp (data, state.data, state.size) != 0)
1479           return pch_option_mismatch (cl_options[i].opt_text);
1480         data += state.size;
1481         len -= state.size;
1482       }
1483
1484   return NULL;
1485 }
1486
1487 /* Default tree printer.   Handles declarations only.  */
1488 static bool
1489 default_tree_printer (pretty_printer * pp, text_info *text, const char *spec,
1490                       int precision, bool wide, bool set_locus, bool hash)
1491 {
1492   tree t;
1493
1494   /* FUTURE: %+x should set the locus.  */
1495   if (precision != 0 || wide || hash)
1496     return false;
1497
1498   switch (*spec)
1499     {
1500     case 'D':
1501       t = va_arg (*text->args_ptr, tree);
1502       if (DECL_DEBUG_EXPR_IS_FROM (t) && DECL_DEBUG_EXPR (t))
1503         t = DECL_DEBUG_EXPR (t);
1504       break;
1505
1506     case 'F':
1507     case 'T':
1508       t = va_arg (*text->args_ptr, tree);
1509       break;
1510
1511     default:
1512       return false;
1513     }
1514
1515   if (set_locus && text->locus)
1516     *text->locus = DECL_SOURCE_LOCATION (t);
1517
1518   if (DECL_P (t))
1519     {
1520       const char *n = DECL_NAME (t)
1521         ? lang_hooks.decl_printable_name (t, 2)
1522         : "<anonymous>";
1523       pp_string (pp, n);
1524     }
1525   else
1526     dump_generic_node (pp, t, 0, TDF_DIAGNOSTIC, 0);
1527
1528   return true;
1529 }
1530
1531 /* A helper function; used as the reallocator function for cpp's line
1532    table.  */
1533 static void *
1534 realloc_for_line_map (void *ptr, size_t len)
1535 {
1536   return ggc_realloc (ptr, len);
1537 }
1538
1539 /* Initialization of the front end environment, before command line
1540    options are parsed.  Signal handlers, internationalization etc.
1541    ARGV0 is main's argv[0].  */
1542 static void
1543 general_init (const char *argv0)
1544 {
1545   const char *p;
1546
1547   p = argv0 + strlen (argv0);
1548   while (p != argv0 && !IS_DIR_SEPARATOR (p[-1]))
1549     --p;
1550   progname = p;
1551
1552   xmalloc_set_program_name (progname);
1553
1554   hex_init ();
1555
1556   /* Unlock the stdio streams.  */
1557   unlock_std_streams ();
1558
1559   gcc_init_libintl ();
1560
1561   /* Initialize the diagnostics reporting machinery, so option parsing
1562      can give warnings and errors.  */
1563   diagnostic_initialize (global_dc);
1564   /* Set a default printer.  Language specific initializations will
1565      override it later.  */
1566   pp_format_decoder (global_dc->printer) = &default_tree_printer;
1567
1568   /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages.  */
1569 #ifdef SIGSEGV
1570   signal (SIGSEGV, crash_signal);
1571 #endif
1572 #ifdef SIGILL
1573   signal (SIGILL, crash_signal);
1574 #endif
1575 #ifdef SIGBUS
1576   signal (SIGBUS, crash_signal);
1577 #endif
1578 #ifdef SIGABRT
1579   signal (SIGABRT, crash_signal);
1580 #endif
1581 #if defined SIGIOT && (!defined SIGABRT || SIGABRT != SIGIOT)
1582   signal (SIGIOT, crash_signal);
1583 #endif
1584 #ifdef SIGFPE
1585   signal (SIGFPE, crash_signal);
1586 #endif
1587
1588   /* Other host-specific signal setup.  */
1589   (*host_hooks.extra_signals)();
1590
1591   /* Initialize the garbage-collector, string pools and tree type hash
1592      table.  */
1593   init_ggc ();
1594   init_stringpool ();
1595   line_table = GGC_NEW (struct line_maps);
1596   linemap_init (line_table);
1597   line_table->reallocator = realloc_for_line_map;
1598   init_ttree ();
1599
1600   /* Initialize register usage now so switches may override.  */
1601   init_reg_sets ();
1602
1603   /* Register the language-independent parameters.  */
1604   add_params (lang_independent_params, LAST_PARAM);
1605
1606   /* This must be done after add_params but before argument processing.  */
1607   init_ggc_heuristics();
1608   init_optimization_passes ();
1609   statistics_early_init ();
1610 }
1611
1612 /* Return true if the current target supports -fsection-anchors.  */
1613
1614 static bool
1615 target_supports_section_anchors_p (void)
1616 {
1617   if (targetm.min_anchor_offset == 0 && targetm.max_anchor_offset == 0)
1618     return false;
1619
1620   if (targetm.asm_out.output_anchor == NULL)
1621     return false;
1622
1623   return true;
1624 }
1625
1626 /* Default the align_* variables to 1 if they're still unset, and
1627    set up the align_*_log variables.  */
1628 static void
1629 init_alignments (void)
1630 {
1631   if (align_loops <= 0)
1632     align_loops = 1;
1633   if (align_loops_max_skip > align_loops)
1634     align_loops_max_skip = align_loops - 1;
1635   align_loops_log = floor_log2 (align_loops * 2 - 1);
1636   if (align_jumps <= 0)
1637     align_jumps = 1;
1638   if (align_jumps_max_skip > align_jumps)
1639     align_jumps_max_skip = align_jumps - 1;
1640   align_jumps_log = floor_log2 (align_jumps * 2 - 1);
1641   if (align_labels <= 0)
1642     align_labels = 1;
1643   align_labels_log = floor_log2 (align_labels * 2 - 1);
1644   if (align_labels_max_skip > align_labels)
1645     align_labels_max_skip = align_labels - 1;
1646   if (align_functions <= 0)
1647     align_functions = 1;
1648   align_functions_log = floor_log2 (align_functions * 2 - 1);
1649 }
1650
1651 /* Process the options that have been parsed.  */
1652 static void
1653 process_options (void)
1654 {
1655   /* Just in case lang_hooks.post_options ends up calling a debug_hook.
1656      This can happen with incorrect pre-processed input. */
1657   debug_hooks = &do_nothing_debug_hooks;
1658
1659   /* This replaces set_Wunused.  */
1660   if (warn_unused_function == -1)
1661     warn_unused_function = warn_unused;
1662   if (warn_unused_label == -1)
1663     warn_unused_label = warn_unused;
1664   /* Wunused-parameter is enabled if both -Wunused -Wextra are enabled.  */
1665   if (warn_unused_parameter == -1)
1666     warn_unused_parameter = (warn_unused && extra_warnings);
1667   if (warn_unused_variable == -1)
1668     warn_unused_variable = warn_unused;
1669   if (warn_unused_value == -1)
1670     warn_unused_value = warn_unused;
1671
1672   /* Allow the front end to perform consistency checks and do further
1673      initialization based on the command line options.  This hook also
1674      sets the original filename if appropriate (e.g. foo.i -> foo.c)
1675      so we can correctly initialize debug output.  */
1676   no_backend = lang_hooks.post_options (&main_input_filename);
1677
1678 #ifdef OVERRIDE_OPTIONS
1679   /* Some machines may reject certain combinations of options.  */
1680   OVERRIDE_OPTIONS;
1681 #endif
1682
1683   if (flag_section_anchors && !target_supports_section_anchors_p ())
1684     {
1685       warning (OPT_fsection_anchors,
1686                "this target does not support %qs", "-fsection-anchors");
1687       flag_section_anchors = 0;
1688     }
1689
1690   if (flag_short_enums == 2)
1691     flag_short_enums = targetm.default_short_enums ();
1692
1693   /* Set aux_base_name if not already set.  */
1694   if (aux_base_name)
1695     ;
1696   else if (main_input_filename)
1697     {
1698       char *name = xstrdup (lbasename (main_input_filename));
1699
1700       strip_off_ending (name, strlen (name));
1701       aux_base_name = name;
1702     }
1703   else
1704     aux_base_name = "gccaux";
1705
1706 #ifndef HAVE_cloog
1707   if (flag_graphite
1708       || flag_loop_block
1709       || flag_loop_interchange
1710       || flag_loop_strip_mine
1711       || flag_graphite_identity)
1712     sorry ("Graphite loop optimizations cannot be used");
1713 #endif
1714
1715   /* Unrolling all loops implies that standard loop unrolling must also
1716      be done.  */
1717   if (flag_unroll_all_loops)
1718     flag_unroll_loops = 1;
1719
1720   /* The loop unrolling code assumes that cse will be run after loop.
1721      web and rename-registers also help when run after loop unrolling.  */
1722
1723   if (flag_rerun_cse_after_loop == AUTODETECT_VALUE)
1724     flag_rerun_cse_after_loop = flag_unroll_loops || flag_peel_loops;
1725   if (flag_web == AUTODETECT_VALUE)
1726     flag_web = flag_unroll_loops || flag_peel_loops;
1727   if (flag_rename_registers == AUTODETECT_VALUE)
1728     flag_rename_registers = flag_unroll_loops || flag_peel_loops;
1729
1730   if (flag_non_call_exceptions)
1731     flag_asynchronous_unwind_tables = 1;
1732   if (flag_asynchronous_unwind_tables)
1733     flag_unwind_tables = 1;
1734
1735   if (flag_value_profile_transformations)
1736     flag_profile_values = 1;
1737
1738   /* Warn about options that are not supported on this machine.  */
1739 #ifndef INSN_SCHEDULING
1740   if (flag_schedule_insns || flag_schedule_insns_after_reload)
1741     warning (0, "instruction scheduling not supported on this target machine");
1742 #endif
1743 #ifndef DELAY_SLOTS
1744   if (flag_delayed_branch)
1745     warning (0, "this target machine does not have delayed branches");
1746 #endif
1747
1748   user_label_prefix = USER_LABEL_PREFIX;
1749   if (flag_leading_underscore != -1)
1750     {
1751       /* If the default prefix is more complicated than "" or "_",
1752          issue a warning and ignore this option.  */
1753       if (user_label_prefix[0] == 0 ||
1754           (user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
1755         {
1756           user_label_prefix = flag_leading_underscore ? "_" : "";
1757         }
1758       else
1759         warning (0, "-f%sleading-underscore not supported on this target machine",
1760                  flag_leading_underscore ? "" : "no-");
1761     }
1762
1763   /* If we are in verbose mode, write out the version and maybe all the
1764      option flags in use.  */
1765   if (version_flag)
1766     {
1767       print_version (stderr, "");
1768       if (! quiet_flag)
1769         print_switch_values (print_to_stderr);
1770     }
1771
1772   if (flag_syntax_only)
1773     {
1774       write_symbols = NO_DEBUG;
1775       profile_flag = 0;
1776     }
1777
1778   /* A lot of code assumes write_symbols == NO_DEBUG if the debugging
1779      level is 0.  */
1780   if (debug_info_level == DINFO_LEVEL_NONE)
1781     write_symbols = NO_DEBUG;
1782
1783   /* Now we know write_symbols, set up the debug hooks based on it.
1784      By default we do nothing for debug output.  */
1785   if (PREFERRED_DEBUGGING_TYPE == NO_DEBUG)
1786     default_debug_hooks = &do_nothing_debug_hooks;
1787 #if defined(DBX_DEBUGGING_INFO)
1788   else if (PREFERRED_DEBUGGING_TYPE == DBX_DEBUG)
1789     default_debug_hooks = &dbx_debug_hooks;
1790 #endif
1791 #if defined(XCOFF_DEBUGGING_INFO)
1792   else if (PREFERRED_DEBUGGING_TYPE == XCOFF_DEBUG)
1793     default_debug_hooks = &xcoff_debug_hooks;
1794 #endif
1795 #ifdef SDB_DEBUGGING_INFO
1796   else if (PREFERRED_DEBUGGING_TYPE == SDB_DEBUG)
1797     default_debug_hooks = &sdb_debug_hooks;
1798 #endif
1799 #ifdef DWARF2_DEBUGGING_INFO
1800   else if (PREFERRED_DEBUGGING_TYPE == DWARF2_DEBUG)
1801     default_debug_hooks = &dwarf2_debug_hooks;
1802 #endif
1803 #ifdef VMS_DEBUGGING_INFO
1804   else if (PREFERRED_DEBUGGING_TYPE == VMS_DEBUG
1805            || PREFERRED_DEBUGGING_TYPE == VMS_AND_DWARF2_DEBUG)
1806     default_debug_hooks = &vmsdbg_debug_hooks;
1807 #endif
1808
1809   if (write_symbols == NO_DEBUG)
1810     ;
1811 #if defined(DBX_DEBUGGING_INFO)
1812   else if (write_symbols == DBX_DEBUG)
1813     debug_hooks = &dbx_debug_hooks;
1814 #endif
1815 #if defined(XCOFF_DEBUGGING_INFO)
1816   else if (write_symbols == XCOFF_DEBUG)
1817     debug_hooks = &xcoff_debug_hooks;
1818 #endif
1819 #ifdef SDB_DEBUGGING_INFO
1820   else if (write_symbols == SDB_DEBUG)
1821     debug_hooks = &sdb_debug_hooks;
1822 #endif
1823 #ifdef DWARF2_DEBUGGING_INFO
1824   else if (write_symbols == DWARF2_DEBUG)
1825     debug_hooks = &dwarf2_debug_hooks;
1826 #endif
1827 #ifdef VMS_DEBUGGING_INFO
1828   else if (write_symbols == VMS_DEBUG || write_symbols == VMS_AND_DWARF2_DEBUG)
1829     debug_hooks = &vmsdbg_debug_hooks;
1830 #endif
1831   else
1832     error ("target system does not support the \"%s\" debug format",
1833            debug_type_names[write_symbols]);
1834
1835   /* Now we know which debug output will be used so we can set
1836      flag_var_tracking, flag_rename_registers if the user has
1837      not specified them.  */
1838   if (debug_info_level < DINFO_LEVEL_NORMAL
1839       || debug_hooks->var_location == do_nothing_debug_hooks.var_location)
1840     {
1841       if (flag_var_tracking == 1
1842           || flag_var_tracking_uninit == 1)
1843         {
1844           if (debug_info_level < DINFO_LEVEL_NORMAL)
1845             warning (0, "variable tracking requested, but useless unless "
1846                      "producing debug info");
1847           else
1848             warning (0, "variable tracking requested, but not supported "
1849                      "by this debug format");
1850         }
1851       flag_var_tracking = 0;
1852       flag_var_tracking_uninit = 0;
1853     }
1854
1855   if (flag_rename_registers == AUTODETECT_VALUE)
1856     flag_rename_registers = default_debug_hooks->var_location
1857                             != do_nothing_debug_hooks.var_location;
1858
1859   if (flag_var_tracking == AUTODETECT_VALUE)
1860     flag_var_tracking = optimize >= 1;
1861
1862   if (flag_tree_cselim == AUTODETECT_VALUE)
1863 #ifdef HAVE_conditional_move
1864     flag_tree_cselim = 1;
1865 #else
1866     flag_tree_cselim = 0;
1867 #endif
1868
1869   /* If the user specifically requested variable tracking with tagging
1870      uninitialized variables, we need to turn on variable tracking.
1871      (We already determined above that variable tracking is feasible.)  */
1872   if (flag_var_tracking_uninit)
1873     flag_var_tracking = 1;
1874
1875   /* If auxiliary info generation is desired, open the output file.
1876      This goes in the same directory as the source file--unlike
1877      all the other output files.  */
1878   if (flag_gen_aux_info)
1879     {
1880       aux_info_file = fopen (aux_info_file_name, "w");
1881       if (aux_info_file == 0)
1882         fatal_error ("can%'t open %s: %m", aux_info_file_name);
1883     }
1884
1885   if (! targetm.have_named_sections)
1886     {
1887       if (flag_function_sections)
1888         {
1889           warning (0, "-ffunction-sections not supported for this target");
1890           flag_function_sections = 0;
1891         }
1892       if (flag_data_sections)
1893         {
1894           warning (0, "-fdata-sections not supported for this target");
1895           flag_data_sections = 0;
1896         }
1897     }
1898
1899   if (flag_function_sections && profile_flag)
1900     {
1901       warning (0, "-ffunction-sections disabled; it makes profiling impossible");
1902       flag_function_sections = 0;
1903     }
1904
1905 #ifndef HAVE_prefetch
1906   if (flag_prefetch_loop_arrays)
1907     {
1908       warning (0, "-fprefetch-loop-arrays not supported for this target");
1909       flag_prefetch_loop_arrays = 0;
1910     }
1911 #else
1912   if (flag_prefetch_loop_arrays && !HAVE_prefetch)
1913     {
1914       warning (0, "-fprefetch-loop-arrays not supported for this target (try -march switches)");
1915       flag_prefetch_loop_arrays = 0;
1916     }
1917 #endif
1918
1919   /* This combination of options isn't handled for i386 targets and doesn't
1920      make much sense anyway, so don't allow it.  */
1921   if (flag_prefetch_loop_arrays && optimize_size)
1922     {
1923       warning (0, "-fprefetch-loop-arrays is not supported with -Os");
1924       flag_prefetch_loop_arrays = 0;
1925     }
1926
1927   /* The presence of IEEE signaling NaNs, implies all math can trap.  */
1928   if (flag_signaling_nans)
1929     flag_trapping_math = 1;
1930
1931   /* We cannot reassociate if we want traps or signed zeros. Â */
1932   if (flag_associative_math && (flag_trapping_math || flag_signed_zeros))
1933     {
1934       warning (0, "-fassociative-math disabled; other options take precedence");
1935       flag_associative_math = 0;
1936     }
1937
1938   /* With -fcx-limited-range, we do cheap and quick complex arithmetic.  */
1939   if (flag_cx_limited_range)
1940     flag_complex_method = 0;
1941
1942   /* With -fcx-fortran-rules, we do something in-between cheap and C99.  */
1943   if (flag_cx_fortran_rules)
1944     flag_complex_method = 1;
1945
1946   /* Targets must be able to place spill slots at lower addresses.  If the
1947      target already uses a soft frame pointer, the transition is trivial.  */
1948   if (!FRAME_GROWS_DOWNWARD && flag_stack_protect)
1949     {
1950       warning (0, "-fstack-protector not supported for this target");
1951       flag_stack_protect = 0;
1952     }
1953   if (!flag_stack_protect)
1954     warn_stack_protect = 0;
1955
1956   /* ??? Unwind info is not correct around the CFG unless either a frame
1957      pointer is present or A_O_A is set.  Fixing this requires rewriting
1958      unwind info generation to be aware of the CFG and propagating states
1959      around edges.  */
1960   if (flag_unwind_tables && !ACCUMULATE_OUTGOING_ARGS
1961       && flag_omit_frame_pointer)
1962     {
1963       warning (0, "unwind tables currently require a frame pointer "
1964                "for correctness");
1965       flag_omit_frame_pointer = 0;
1966     }
1967 }
1968
1969 /* This function can be called multiple times to reinitialize the compiler
1970    back end when register classes or instruction sets have changed,
1971    before each function.  */
1972 static void
1973 backend_init_target (void)
1974 {
1975   /* Initialize alignment variables.  */
1976   init_alignments ();
1977
1978   /* This reinitializes hard_frame_pointer, and calls init_reg_modes_target()
1979      to initialize reg_raw_mode[].  */
1980   init_emit_regs ();
1981
1982   /* This invokes target hooks to set fixed_reg[] etc, which is
1983      mode-dependent.  */
1984   init_regs ();
1985
1986   /* This depends on stack_pointer_rtx.  */
1987   init_fake_stack_mems ();
1988
1989   /* Sets static_base_value[HARD_FRAME_POINTER_REGNUM], which is
1990      mode-dependent.  */
1991   init_alias_target ();
1992
1993   /* Depends on HARD_FRAME_POINTER_REGNUM.  */
1994   init_reload ();
1995
1996   /* The following initialization functions need to generate rtl, so
1997      provide a dummy function context for them.  */
1998   init_dummy_function_start ();
1999
2000   /* rtx_cost is mode-dependent, so cached values need to be recomputed
2001      on a mode change.  */
2002   init_expmed ();
2003
2004   /* We may need to recompute regno_save_code[] and regno_restore_code[]
2005      after a mode change as well.  */
2006   if (flag_caller_saves)
2007     init_caller_save ();
2008   expand_dummy_function_end ();
2009 }
2010
2011 /* Initialize the compiler back end.  This function is called only once,
2012    when starting the compiler.  */
2013 static void
2014 backend_init (void)
2015 {
2016   init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
2017                   || debug_info_level == DINFO_LEVEL_VERBOSE
2018 #ifdef VMS_DEBUGGING_INFO
2019                     /* Enable line number info for traceback.  */
2020                     || debug_info_level > DINFO_LEVEL_NONE
2021 #endif
2022                     || flag_test_coverage);
2023
2024   init_rtlanal ();
2025   init_inline_once ();
2026   init_varasm_once ();
2027   save_register_info ();
2028
2029   /* Initialize the target-specific back end pieces.  */
2030   ira_init_once ();
2031   backend_init_target ();
2032 }
2033
2034 /* Initialize things that are both lang-dependent and target-dependent.
2035    This function can be called more than once if target parameters change.  */
2036 static void
2037 lang_dependent_init_target (void)
2038 {
2039   /* This creates various _DECL nodes, so needs to be called after the
2040      front end is initialized.  It also depends on the HAVE_xxx macros
2041      generated from the target machine description.  */
2042   init_optabs ();
2043
2044   /* The following initialization functions need to generate rtl, so
2045      provide a dummy function context for them.  */
2046   init_dummy_function_start ();
2047
2048   /* Do the target-specific parts of expr initialization.  */
2049   init_expr_target ();
2050
2051   /* Although the actions of these functions are language-independent,
2052      they use optabs, so we cannot call them from backend_init.  */
2053   init_set_costs ();
2054   ira_init ();
2055
2056   expand_dummy_function_end ();
2057 }
2058
2059 /* Language-dependent initialization.  Returns nonzero on success.  */
2060 static int
2061 lang_dependent_init (const char *name)
2062 {
2063   location_t save_loc = input_location;
2064   if (dump_base_name == 0)
2065     dump_base_name = name && name[0] ? name : "gccdump";
2066
2067   /* Other front-end initialization.  */
2068   input_location = BUILTINS_LOCATION;
2069   if (lang_hooks.init () == 0)
2070     return 0;
2071   input_location = save_loc;
2072
2073   init_asm_output (name);
2074
2075   /* This creates various _DECL nodes, so needs to be called after the
2076      front end is initialized.  */
2077   init_eh ();
2078
2079   /* Do the target-specific parts of the initialization.  */
2080   lang_dependent_init_target ();
2081
2082   /* If dbx symbol table desired, initialize writing it and output the
2083      predefined types.  */
2084   timevar_push (TV_SYMOUT);
2085
2086 #if defined DWARF2_DEBUGGING_INFO || defined DWARF2_UNWIND_INFO
2087   if (dwarf2out_do_frame ())
2088     dwarf2out_frame_init ();
2089 #endif
2090
2091   /* Now we have the correct original filename, we can initialize
2092      debug output.  */
2093   (*debug_hooks->init) (name);
2094
2095   timevar_pop (TV_SYMOUT);
2096
2097   return 1;
2098 }
2099
2100
2101 /* Reinitialize everything when target parameters, such as register usage,
2102    have changed.  */
2103 void
2104 target_reinit (void)
2105 {
2106   /* Reinitialize RTL backend.  */
2107   backend_init_target ();
2108
2109   /* Reinitialize lang-dependent parts.  */
2110   lang_dependent_init_target ();
2111 }
2112
2113 void
2114 dump_memory_report (bool final)
2115 {
2116   ggc_print_statistics ();
2117   stringpool_statistics ();
2118   dump_tree_statistics ();
2119   dump_gimple_statistics ();
2120   dump_rtx_statistics ();
2121   dump_varray_statistics ();
2122   dump_alloc_pool_statistics ();
2123   dump_bitmap_statistics ();
2124   dump_vec_loc_statistics ();
2125   dump_ggc_loc_statistics (final);
2126 }
2127
2128 /* Clean up: close opened files, etc.  */
2129
2130 static void
2131 finalize (void)
2132 {
2133   /* Close the dump files.  */
2134   if (flag_gen_aux_info)
2135     {
2136       fclose (aux_info_file);
2137       if (errorcount)
2138         unlink (aux_info_file_name);
2139     }
2140
2141   /* Close non-debugging input and output files.  Take special care to note
2142      whether fclose returns an error, since the pages might still be on the
2143      buffer chain while the file is open.  */
2144
2145   if (asm_out_file)
2146     {
2147       if (ferror (asm_out_file) != 0)
2148         fatal_error ("error writing to %s: %m", asm_file_name);
2149       if (fclose (asm_out_file) != 0)
2150         fatal_error ("error closing %s: %m", asm_file_name);
2151     }
2152
2153   statistics_fini ();
2154   finish_optimization_passes ();
2155
2156   ira_finish_once ();
2157
2158   if (mem_report)
2159     dump_memory_report (true);
2160
2161   /* Language-specific end of compilation actions.  */
2162   lang_hooks.finish ();
2163 }
2164
2165 /* Initialize the compiler, and compile the input file.  */
2166 static void
2167 do_compile (void)
2168 {
2169   /* Initialize timing first.  The C front ends read the main file in
2170      the post_options hook, and C++ does file timings.  */
2171   if (time_report || !quiet_flag  || flag_detailed_statistics)
2172     timevar_init ();
2173   timevar_start (TV_TOTAL);
2174
2175   process_options ();
2176
2177   /* Don't do any more if an error has already occurred.  */
2178   if (!errorcount)
2179     {
2180       /* This must be run always, because it is needed to compute the FP
2181          predefined macros, such as __LDBL_MAX__, for targets using non
2182          default FP formats.  */
2183       init_adjust_machine_modes ();
2184
2185       /* Set up the back-end if requested.  */
2186       if (!no_backend)
2187         backend_init ();
2188
2189       /* Language-dependent initialization.  Returns true on success.  */
2190       if (lang_dependent_init (main_input_filename))
2191         compile_file ();
2192
2193       finalize ();
2194     }
2195
2196   /* Stop timing and print the times.  */
2197   timevar_stop (TV_TOTAL);
2198   timevar_print (stderr);
2199 }
2200
2201 /* Entry point of cc1, cc1plus, jc1, f771, etc.
2202    Exit code is FATAL_EXIT_CODE if can't open files or if there were
2203    any errors, or SUCCESS_EXIT_CODE if compilation succeeded.
2204
2205    It is not safe to call this function more than once.  */
2206
2207 int
2208 toplev_main (unsigned int argc, const char **argv)
2209 {
2210   save_argv = argv;
2211
2212   /* Initialization of GCC's environment, and diagnostics.  */
2213   general_init (argv[0]);
2214
2215   /* Parse the options and do minimal processing; basically just
2216      enough to default flags appropriately.  */
2217   decode_options (argc, argv);
2218
2219   init_local_tick ();
2220
2221   /* Exit early if we can (e.g. -help).  */
2222   if (!exit_after_options)
2223     do_compile ();
2224
2225   if (warningcount || errorcount) 
2226     print_ignored_options ();
2227
2228   if (errorcount || sorrycount)
2229     return (FATAL_EXIT_CODE);
2230
2231   return (SUCCESS_EXIT_CODE);
2232 }