#include "integrate.h"
#include "debug.h"
#include "target.h"
+#include "common/common-target.h"
#include "langhooks.h"
#include "cfglayout.h"
#include "cfgloop.h"
const struct gcc_debug_hooks *debug_hooks;
-/* True if this is the lto front end. This is used to disable
- gimple generation and lowering passes that are normally run on the
- output of a front end. These passes must be bypassed for lto since
- they have already been done before the gimple was written. */
-
-bool in_lto_p = false;
-
/* The FUNCTION_DECL for the function currently being compiled,
or 0 if between functions. */
tree current_function_decl;
user has specified a particular random seed. */
unsigned local_tick;
-/* -f flags. */
+/* Random number for this compilation */
+HOST_WIDE_INT random_seed;
-/* Generate code for GNU or NeXT Objective-C runtime environment. */
-
-#ifdef NEXT_OBJC_RUNTIME
-int flag_next_runtime = 1;
-#else
-int flag_next_runtime = 0;
-#endif
+/* -f flags. */
/* Nonzero means make permerror produce warnings instead of errors. */
#define this_target_flag_state (&default_target_flag_state)
#endif
-typedef struct
-{
- const char *const string;
- int *const variable;
- const int on_value;
-}
-lang_independent_options;
-
/* The user symbol prefix after having resolved same. */
const char *user_label_prefix;
-static const param_info lang_independent_params[] = {
-#define DEFPARAM(ENUM, OPTION, HELP, DEFAULT, MIN, MAX) \
- { OPTION, DEFAULT, MIN, MAX, HELP },
-#include "params.def"
-#undef DEFPARAM
- { NULL, 0, 0, 0, NULL }
-};
-
/* Output files for assembler code (real compiler output)
and debugging dumps. */
}
}
-/* Initialize local_tick with the time of day, or -1 if
+/* Initialize local_tick with a random number or -1 if
flag_random_seed is set. */
static void
{
if (!flag_random_seed)
{
- /* Get some more or less random data. */
+ /* Try urandom first. Time of day is too likely to collide.
+ In case of any error we just use the local tick. */
+
+ int fd = open ("/dev/urandom", O_RDONLY);
+ if (fd >= 0)
+ {
+ read (fd, &random_seed, sizeof (random_seed));
+ close (fd);
+ }
+
+ /* Now get the tick anyways */
#ifdef HAVE_GETTIMEOFDAY
{
struct timeval tv;
static void
init_random_seed (void)
{
- unsigned HOST_WIDE_INT value;
- static char random_seed[HOST_BITS_PER_WIDE_INT / 4 + 3];
-
- value = local_tick ^ getpid ();
+ if (flag_random_seed)
+ {
+ char *endp;
- sprintf (random_seed, HOST_WIDE_INT_PRINT_HEX, value);
- flag_random_seed = random_seed;
+ /* When the driver passed in a hex number don't crc it again */
+ random_seed = strtoul (flag_random_seed, &endp, 0);
+ if (!(endp > flag_random_seed && *endp == 0))
+ random_seed = crc32_string (0, flag_random_seed);
+ }
+ else if (!random_seed)
+ random_seed = local_tick ^ getpid (); /* Old racey fallback method */
}
-/* Obtain the random_seed string. Unless NOINIT, initialize it if
+/* Obtain the random_seed. Unless NOINIT, initialize it if
it's not provided in the command line. */
-const char *
+HOST_WIDE_INT
get_random_seed (bool noinit)
{
if (!flag_random_seed && !noinit)
init_random_seed ();
- return flag_random_seed;
+ return random_seed;
}
/* Modify the random_seed string to VAL. Return its previous
static void
compile_file (void)
{
- /* Initialize yet another pass. */
-
- ggc_protect_identifiers = true;
-
- init_cgraph ();
- init_final (main_input_filename);
- coverage_init (aux_base_name);
- statistics_init ();
- invoke_plugin_callbacks (PLUGIN_START_UNIT, NULL);
-
- timevar_push (TV_PARSE);
+ timevar_start (TV_PHASE_PARSING);
+ timevar_push (TV_PARSE_GLOBAL);
/* Call the parser, which parses the entire file (calling
rest_of_compilation for each function). */
lang_hooks.parse_file ();
+ timevar_pop (TV_PARSE_GLOBAL);
+ timevar_stop (TV_PHASE_PARSING);
+
/* Compilation is now finished except for writing
what's left of the symbol table output. */
- timevar_pop (TV_PARSE);
if (flag_syntax_only || flag_wpa)
return;
+ timevar_start (TV_PHASE_GENERATE);
+
ggc_protect_identifiers = false;
/* This must also call cgraph_finalize_compilation_unit. */
lang_hooks.decls.final_write_globals ();
if (seen_error ())
- return;
+ {
+ timevar_stop (TV_PHASE_GENERATE);
+ return;
+ }
- varpool_assemble_pending_decls ();
- finish_aliases_2 ();
+ /* Compilation unit is finalized. When producing non-fat LTO object, we are
+ basically finished. */
+ if (in_lto_p || !flag_lto || flag_fat_lto_objects)
+ {
+ varpool_assemble_pending_decls ();
+ finish_aliases_2 ();
- /* Likewise for mudflap static object registrations. */
- if (flag_mudflap)
- mudflap_finish_file ();
+ /* Likewise for mudflap static object registrations. */
+ if (flag_mudflap)
+ mudflap_finish_file ();
- output_shared_constant_pool ();
- output_object_blocks ();
+ output_shared_constant_pool ();
+ output_object_blocks ();
+ finish_tm_clone_pairs ();
- /* Write out any pending weak symbol declarations. */
- weak_finish ();
+ /* Write out any pending weak symbol declarations. */
+ weak_finish ();
- /* This must be at the end before unwind and debug info.
- Some target ports emit PIC setup thunks here. */
- targetm.asm_out.code_end ();
+ /* This must be at the end before unwind and debug info.
+ Some target ports emit PIC setup thunks here. */
+ targetm.asm_out.code_end ();
- /* Do dbx symbols. */
- timevar_push (TV_SYMOUT);
+ /* Do dbx symbols. */
+ timevar_push (TV_SYMOUT);
-#if defined DWARF2_DEBUGGING_INFO || defined DWARF2_UNWIND_INFO
- if (dwarf2out_do_frame ())
- dwarf2out_frame_finish ();
-#endif
+ #if defined DWARF2_DEBUGGING_INFO || defined DWARF2_UNWIND_INFO
+ if (dwarf2out_do_frame ())
+ dwarf2out_frame_finish ();
+ #endif
- (*debug_hooks->finish) (main_input_filename);
- timevar_pop (TV_SYMOUT);
+ (*debug_hooks->finish) (main_input_filename);
+ timevar_pop (TV_SYMOUT);
- /* Output some stuff at end of file if nec. */
+ /* Output some stuff at end of file if nec. */
- dw2_output_indirect_constants ();
+ dw2_output_indirect_constants ();
- /* Flush any pending external directives. */
- process_pending_assemble_externals ();
+ /* Flush any pending external directives. */
+ process_pending_assemble_externals ();
+ }
/* Emit LTO marker if LTO info has been previously emitted. This is
used by collect2 to determine whether an object file contains IL.
(unsigned HOST_WIDE_INT) 1,
(unsigned HOST_WIDE_INT) 1);
#endif
+ /* Let linker plugin know that this is a slim object and must be LTOed
+ even when user did not ask for it. */
+ if (!flag_fat_lto_objects)
+ {
+#if defined ASM_OUTPUT_ALIGNED_DECL_COMMON
+ ASM_OUTPUT_ALIGNED_DECL_COMMON (asm_out_file, NULL_TREE,
+ "__gnu_lto_slim",
+ (unsigned HOST_WIDE_INT) 1, 8);
+#elif defined ASM_OUTPUT_ALIGNED_COMMON
+ ASM_OUTPUT_ALIGNED_COMMON (asm_out_file, "__gnu_lto_slim",
+ (unsigned HOST_WIDE_INT) 1, 8);
+#else
+ ASM_OUTPUT_COMMON (asm_out_file, "__gnu_lto_slim",
+ (unsigned HOST_WIDE_INT) 1,
+ (unsigned HOST_WIDE_INT) 1);
+#endif
+ }
}
/* Attach a special .ident directive to the end of the file to identify
into the assembly file here, and hence we can not output anything to the
assembly file after this point. */
targetm.asm_out.file_end ();
-}
-/* Indexed by enum debug_info_type. */
-const char *const debug_type_names[] =
-{
- "none", "stabs", "coff", "dwarf-2", "xcoff", "vms"
-};
+ timevar_stop (TV_PHASE_GENERATE);
+}
/* Print version information to FILE.
Each line begins with INDENT (for the case where FILE is the
print_plugins_versions (file, indent);
}
-#ifdef ASM_COMMENT_START
static int
print_to_asm_out_file (print_switch_type type, const char * text)
{
return -1;
}
}
-#endif
static int
print_to_stderr (print_switch_type type, const char * text)
inform (input_location, "-frecord-gcc-switches is not supported by the current target");
}
-#ifdef ASM_COMMENT_START
if (flag_verbose_asm)
{
/* Print the list of switches in effect
print_switch_values (print_to_asm_out_file);
putc ('\n', asm_out_file);
}
-#endif
}
}
};
HOST_WIDE_INT stack_usage = current_function_static_stack_size;
enum stack_usage_kind_type stack_usage_kind;
- expanded_location loc;
- const char *raw_id, *id;
if (stack_usage < 0)
{
if (!warning_issued)
{
- warning (0, "-fstack-usage not supported for this target");
+ warning (0, "stack usage computation not supported for this target");
warning_issued = true;
}
return;
stack_usage += current_function_dynamic_stack_size;
}
- loc = expand_location (DECL_SOURCE_LOCATION (current_function_decl));
+ if (flag_stack_usage)
+ {
+ expanded_location loc
+ = expand_location (DECL_SOURCE_LOCATION (current_function_decl));
+ const char *raw_id, *id;
+
+ /* Strip the scope prefix if any. */
+ raw_id = lang_hooks.decl_printable_name (current_function_decl, 2);
+ id = strrchr (raw_id, '.');
+ if (id)
+ id++;
+ else
+ id = raw_id;
+
+ fprintf (stack_usage_file,
+ "%s:%d:%d:%s\t"HOST_WIDE_INT_PRINT_DEC"\t%s\n",
+ lbasename (loc.file),
+ loc.line,
+ loc.column,
+ id,
+ stack_usage,
+ stack_usage_kind_str[stack_usage_kind]);
+ }
- /* Strip the scope prefix if any. */
- raw_id = lang_hooks.decl_printable_name (current_function_decl, 2);
- id = strrchr (raw_id, '.');
- if (id)
- id++;
- else
- id = raw_id;
-
- fprintf (stack_usage_file,
- "%s:%d:%d:%s\t"HOST_WIDE_INT_PRINT_DEC"\t%s\n",
- lbasename (loc.file),
- loc.line,
- loc.column,
- id,
- stack_usage,
- stack_usage_kind_str[stack_usage_kind]);
+ if (warn_stack_usage >= 0)
+ {
+ if (stack_usage_kind == DYNAMIC)
+ warning (OPT_Wstack_usage_, "stack usage might be unbounded");
+ else if (stack_usage > warn_stack_usage)
+ {
+ if (stack_usage_kind == DYNAMIC_BOUNDED)
+ warning (OPT_Wstack_usage_, "stack usage might be %wd bytes",
+ stack_usage);
+ else
+ warning (OPT_Wstack_usage_, "stack usage is %wd bytes",
+ stack_usage);
+ }
+ }
}
/* Open an auxiliary output file. */
can give warnings and errors. */
diagnostic_initialize (global_dc, N_OPTS);
diagnostic_starter (global_dc) = default_tree_diagnostic_starter;
+ /* By default print macro expansion contexts in the diagnostic
+ finalizer -- for tokens resulting from macro macro expansion. */
+ diagnostic_finalizer (global_dc) = virt_loc_aware_diagnostic_finalizer;
/* Set a default printer. Language specific initializations will
override it later. */
pp_format_decoder (global_dc->printer) = &default_tree_printer;
line_table = ggc_alloc_line_maps ();
linemap_init (line_table);
line_table->reallocator = realloc_for_line_map;
+ line_table->round_alloc_size = ggc_round_alloc_size;
init_ttree ();
/* Initialize register usage now so switches may override. */
init_reg_sets ();
/* Register the language-independent parameters. */
- add_params (lang_independent_params, LAST_PARAM);
- targetm.target_option.default_params ();
+ global_init_params ();
- /* This must be done after add_params but before argument processing. */
+ /* This must be done after global_init_params but before argument
+ processing. */
init_ggc_heuristics();
init_optimization_passes ();
statistics_early_init ();
maximum_field_alignment = initial_max_fld_align * BITS_PER_UNIT;
- /* This replaces set_Wunused. */
- if (warn_unused_function == -1)
- warn_unused_function = warn_unused;
- if (warn_unused_label == -1)
- warn_unused_label = warn_unused;
- /* Wunused-parameter is enabled if both -Wunused -Wextra are enabled. */
- if (warn_unused_parameter == -1)
- warn_unused_parameter = (warn_unused && extra_warnings);
- if (warn_unused_variable == -1)
- warn_unused_variable = warn_unused;
- /* Wunused-but-set-parameter is enabled if both -Wunused -Wextra are
- enabled. */
- if (warn_unused_but_set_parameter == -1)
- warn_unused_but_set_parameter = (warn_unused && extra_warnings);
- if (warn_unused_but_set_variable == -1)
- warn_unused_but_set_variable = warn_unused;
- if (warn_unused_value == -1)
- warn_unused_value = warn_unused;
-
- /* This replaces set_Wextra. */
- if (warn_uninitialized == -1)
- warn_uninitialized = extra_warnings;
-
/* Allow the front end to perform consistency checks and do further
initialization based on the command line options. This hook also
sets the original filename if appropriate (e.g. foo.i -> foo.c)
"and -ftree-loop-linear)");
#endif
+ if (flag_mudflap && flag_lto)
+ sorry ("mudflap cannot be used together with link-time optimization");
+
+ /* One region RA really helps to decrease the code size. */
+ if (flag_ira_region == IRA_REGION_AUTODETECT)
+ flag_ira_region
+ = optimize_size || !optimize ? IRA_REGION_ONE : IRA_REGION_MIXED;
+
+ if (flag_strict_volatile_bitfields > 0 && !abi_version_at_least (2))
+ {
+ warning (0, "-fstrict-volatile-bitfields disabled; "
+ "it is incompatible with ABI versions < 2");
+ flag_strict_volatile_bitfields = 0;
+ }
+
/* Unrolling all loops implies that standard loop unrolling must also
be done. */
if (flag_unroll_all_loops)
fatal_error ("can%'t open %s: %m", aux_info_file_name);
}
- if (! targetm.have_named_sections)
+ if (!targetm_common.have_named_sections)
{
if (flag_function_sections)
{
predefined types. */
timevar_push (TV_SYMOUT);
-#if defined DWARF2_DEBUGGING_INFO || defined DWARF2_UNWIND_INFO
- if (dwarf2out_do_frame ())
- dwarf2out_frame_init ();
-#endif
-
/* Now we have the correct original filename, we can initialize
debug output. */
(*debug_hooks->init) (name);
void
dump_memory_report (bool final)
{
+ dump_line_table_statistics ();
ggc_print_statistics ();
stringpool_statistics ();
dump_tree_statistics ();
/* Don't do any more if an error has already occurred. */
if (!seen_error ())
{
+ timevar_start (TV_PHASE_SETUP);
+
/* This must be run always, because it is needed to compute the FP
predefined macros, such as __LDBL_MAX__, for targets using non
default FP formats. */
/* Language-dependent initialization. Returns true on success. */
if (lang_dependent_init (main_input_filename))
- compile_file ();
+ {
+ /* Initialize yet another pass. */
+
+ ggc_protect_identifiers = true;
+
+ init_cgraph ();
+ init_final (main_input_filename);
+ coverage_init (aux_base_name);
+ statistics_init ();
+ invoke_plugin_callbacks (PLUGIN_START_UNIT, NULL);
+
+ timevar_stop (TV_PHASE_SETUP);
+
+ compile_file ();
+ }
+ else
+ {
+ timevar_stop (TV_PHASE_SETUP);
+ }
+
+ timevar_start (TV_PHASE_FINALIZE);
finalize (no_backend);
+
+ timevar_stop (TV_PHASE_FINALIZE);
}
/* Stop timing and print the times. */
int
toplev_main (int argc, char **argv)
{
+ /* Parsing and gimplification sometimes need quite large stack.
+ Increase stack size limits if possible. */
+ stack_limit_increase (64 * 1024 * 1024);
+
expandargv (&argc, &argv);
/* Initialization of GCC's environment, and diagnostics. */