/* Top level of GCC compilers (cc1, cc1plus, etc.)
Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
- Free Software Foundation, Inc.
+ 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
+ 2011 Free Software Foundation, Inc.
This file is part of GCC.
#include "integrate.h"
#include "debug.h"
#include "target.h"
+#include "common/common-target.h"
#include "langhooks.h"
#include "cfglayout.h"
#include "cfgloop.h"
the support provided depends on the backend. */
rtx stack_limit_rtx;
-/* Type of stack check. */
-enum stack_check_type flag_stack_check = NO_STACK_CHECK;
-
/* True if the user has tagged the function with the 'section'
attribute. */
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 ();
into the assembly file here, and hence we can not output anything to the
assembly file after this point. */
targetm.asm_out.file_end ();
+
+ timevar_stop (TV_PHASE_GENERATE);
}
/* Indexed by enum debug_info_type. */
SWITCH_TYPE_DESCRIPTIVE, _("options enabled: "));
for (j = 0; j < cl_options_count; j++)
- if ((cl_options[j].flags & CL_REPORT)
+ if (cl_options[j].cl_report
&& option_enabled (j, &global_options) > 0)
pos = print_single_switch (print_fn, pos,
SWITCH_TYPE_ENABLED, cl_options[j].opt_text);
};
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. */
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)
#ifndef HAVE_cloog
if (flag_graphite
+ || flag_graphite_identity
|| flag_loop_block
+ || flag_loop_flatten
|| flag_loop_interchange
|| flag_loop_strip_mine
- || flag_graphite_identity
|| flag_loop_parallelize_all)
- sorry ("Graphite loop optimizations cannot be used");
+ sorry ("Graphite loop optimizations cannot be used (-fgraphite, "
+ "-fgraphite-identity, -floop-block, -floop-flatten, "
+ "-floop-interchange, -floop-strip-mine, -floop-parallelize-all, "
+ "and -ftree-loop-linear)");
#endif
/* Unrolling all loops implies that standard loop unrolling must also
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)
{
flag_omit_frame_pointer = 0;
}
+ /* Enable -Werror=coverage-mismatch when -Werror and -Wno-error
+ have not been set. */
+ if (!global_options_set.x_warnings_are_errors
+ && warn_coverage_mismatch
+ && (global_dc->classify_diagnostic[OPT_Wcoverage_mismatch] ==
+ DK_UNSPECIFIED))
+ diagnostic_classify_diagnostic (global_dc, OPT_Wcoverage_mismatch,
+ DK_ERROR, UNKNOWN_LOCATION);
+
/* Save the current optimization options. */
optimization_default_node = build_optimization_node ();
optimization_current_node = optimization_default_node;
return 0;
input_location = save_loc;
- init_asm_output (name);
+ if (!flag_wpa)
+ {
+ init_asm_output (name);
- /* If stack usage information is desired, open the output file. */
- if (flag_stack_usage)
- stack_usage_file = open_auxiliary_file ("su");
+ /* If stack usage information is desired, open the output file. */
+ if (flag_stack_usage)
+ stack_usage_file = open_auxiliary_file ("su");
+ }
/* This creates various _DECL nodes, so needs to be called after the
front end is initialized. */
/* Do the target-specific parts of the initialization. */
lang_dependent_init_target ();
- /* If dbx symbol table desired, initialize writing it and output the
- predefined types. */
- timevar_push (TV_SYMOUT);
+ if (!flag_wpa)
+ {
+ /* If dbx symbol table desired, initialize writing it and output the
+ predefined types. */
+ timevar_push (TV_SYMOUT);
#if defined DWARF2_DEBUGGING_INFO || defined DWARF2_UNWIND_INFO
- if (dwarf2out_do_frame ())
- dwarf2out_frame_init ();
+ if (dwarf2out_do_frame ())
+ dwarf2out_frame_init ();
#endif
- /* Now we have the correct original filename, we can initialize
- debug output. */
- (*debug_hooks->init) (name);
+ /* Now we have the correct original filename, we can initialize
+ debug output. */
+ (*debug_hooks->init) (name);
- timevar_pop (TV_SYMOUT);
+ timevar_pop (TV_SYMOUT);
+ }
return 1;
}
void
target_reinit (void)
{
+ struct rtl_data saved_x_rtl;
+ rtx *saved_regno_reg_rtx;
+
+ /* Save *crtl and regno_reg_rtx around the reinitialization
+ to allow target_reinit being called even after prepare_function_start. */
+ saved_regno_reg_rtx = regno_reg_rtx;
+ if (saved_regno_reg_rtx)
+ {
+ saved_x_rtl = *crtl;
+ memset (crtl, '\0', sizeof (*crtl));
+ regno_reg_rtx = NULL;
+ }
+
/* Reinitialize RTL backend. */
backend_init_target ();
/* Reinitialize lang-dependent parts. */
lang_dependent_init_target ();
+
+ /* And restore it at the end, as free_after_compilation from
+ expand_dummy_function_end clears it. */
+ if (saved_regno_reg_rtx)
+ {
+ *crtl = saved_x_rtl;
+ regno_reg_rtx = saved_regno_reg_rtx;
+ saved_regno_reg_rtx = NULL;
+ }
}
void
fatal_error ("error writing to %s: %m", asm_file_name);
if (fclose (asm_out_file) != 0)
fatal_error ("error closing %s: %m", asm_file_name);
- if (flag_wpa)
- unlink_if_ordinary (asm_file_name);
}
if (stack_usage_file)
/* 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. */