diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d097e38c3ea..0a29202d65b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,22 @@ +2004-04-17 Paolo Bonzini + + * opts.c (decode_options): Do not enable flag_rename_registers + and flag_web at -O3. + * toplev.c (flag_rename_registers): Initialize + flag_rename_registers and flag_web to + AUTODETECT_FLAG_VAR_TRACKING. + (default_debug_hooks): New global. + (process_options): Initialize default_debug_hooks. Warn if + -fvar-tracking specified but not supported by the current + debug format. Do not run var tracking at -O0 or if not + supported by the current debug format, even if + -fvar-tracking was given. If -fno-rename-registers + is not specified, always run register renaming if var + tracking is supported by the default debugging information + format for the target, and we are at -O1 or higher; similarly + for -fweb, but only at -O2 or higher. + * doc/invoke.texi (Optimize Options): Document this. + 2004-04-17 Richard Sandiford * configure.ac (gcc_cv_ld_as_needed): Use AC_CACHE_CHECK. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 60611f22c15..152919406d8 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -4346,11 +4346,14 @@ Enabled at levels @option{-O2}, @option{-O3}. @opindex frename-registers Attempt to avoid false dependencies in scheduled code by making use of registers left over after register allocation. This optimization -will most benefit processors with lots of registers. It can, however, +will most benefit processors with lots of registers. Depending on the +debug information format adopted by the target, however, it can make debugging impossible, since variables will no longer stay in a ``home register''. -Enabled at levels @option{-O3}. +Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}, +on targets where the default format for debugging information supports +variable tracking. @item -fweb @opindex fweb @@ -4361,7 +4364,9 @@ passes, such as CSE, loop optimizer and trivial dead code remover. It can, however, make debugging impossible, since variables will no longer stay in a ``home register''. -Enabled at levels @option{-O3}. +Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}, +on targets where the default format for debugging information supports +variable tracking. @item -fno-cprop-registers @opindex fno-cprop-registers diff --git a/gcc/opts.c b/gcc/opts.c index a2df41a489a..fb04b8fbb41 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -571,9 +571,7 @@ decode_options (unsigned int argc, const char **argv) if (optimize >= 3) { flag_inline_functions = 1; - flag_rename_registers = 1; flag_unswitch_loops = 1; - flag_web = 1; flag_gcse_after_reload = 1; } diff --git a/gcc/toplev.c b/gcc/toplev.c index 39b2ddf1f6f..faf177af55f 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -138,6 +138,10 @@ static const char **save_argv; const char *main_input_filename; +/* Used to enable -fvar-tracking, -fweb and -frename-registers according + to optimize and default_debug_hooks in process_options (). */ +#define AUTODETECT_FLAG_VAR_TRACKING 2 + /* Current position in real source file. */ location_t input_location; @@ -177,6 +181,10 @@ int target_flags_explicit; const struct gcc_debug_hooks *debug_hooks; +/* Debug hooks - target default. */ + +static const struct gcc_debug_hooks *default_debug_hooks; + /* Other flags saying which kinds of debugging dump have been requested. */ int rtl_dump_and_exit; @@ -258,9 +266,10 @@ int flag_reorder_blocks_and_partition = 0; int flag_reorder_functions = 0; -/* Nonzero if registers should be renamed. */ - -int flag_rename_registers = 0; +/* Nonzero if registers should be renamed. When + flag_rename_registers == AUTODETECT_FLAG_VAR_TRACKING it will be set + according to optimize and default_debug_hooks in process_options (). */ +int flag_rename_registers = AUTODETECT_FLAG_VAR_TRACKING; int flag_cprop_registers = 0; /* Nonzero for -pedantic switch: warn about anything @@ -485,9 +494,11 @@ int flag_complex_divide_method = 0; int flag_syntax_only = 0; -/* Nonzero means performs web construction pass. */ +/* Nonzero means performs web construction pass. When flag_web == + AUTODETECT_FLAG_VAR_TRACKING it will be set according to optimize + and default_debug_hooks in process_options (). */ -int flag_web; +int flag_web = AUTODETECT_FLAG_VAR_TRACKING; /* Nonzero means perform loop optimizer. */ @@ -800,8 +811,6 @@ int flag_unit_at_a_time = 0; /* Nonzero if we should track variables. When flag_var_tracking == AUTODETECT_FLAG_VAR_TRACKING it will be set according to optimize, debug_info_level and debug_hooks in process_options (). */ - -#define AUTODETECT_FLAG_VAR_TRACKING 2 int flag_var_tracking = AUTODETECT_FLAG_VAR_TRACKING; /* Values of the -falign-* flags: how much to align labels in code. @@ -2335,6 +2344,30 @@ process_options (void) /* Now we know write_symbols, set up the debug hooks based on it. By default we do nothing for debug output. */ + if (PREFERRED_DEBUGGING_TYPE == NO_DEBUG) + default_debug_hooks = &do_nothing_debug_hooks; +#if defined(DBX_DEBUGGING_INFO) + else if (PREFERRED_DEBUGGING_TYPE == DBX_DEBUG) + default_debug_hooks = &dbx_debug_hooks; +#endif +#if defined(XCOFF_DEBUGGING_INFO) + else if (PREFERRED_DEBUGGING_TYPE == XCOFF_DEBUG) + default_debug_hooks = &xcoff_debug_hooks; +#endif +#ifdef SDB_DEBUGGING_INFO + else if (PREFERRED_DEBUGGING_TYPE == SDB_DEBUG) + default_debug_hooks = &sdb_debug_hooks; +#endif +#ifdef DWARF2_DEBUGGING_INFO + else if (PREFERRED_DEBUGGING_TYPE == DWARF2_DEBUG) + default_debug_hooks = &dwarf2_debug_hooks; +#endif +#ifdef VMS_DEBUGGING_INFO + else if (PREFERRED_DEBUGGING_TYPE == VMS_DEBUG + || PREFERRED_DEBUGGING_TYPE == VMS_AND_DWARF2_DEBUG) + default_debug_hooks = &vmsdbg_debug_hooks; +#endif + if (write_symbols == NO_DEBUG) debug_hooks = &do_nothing_debug_hooks; #if defined(DBX_DEBUGGING_INFO) @@ -2362,15 +2395,34 @@ process_options (void) debug_type_names[write_symbols]); /* Now we know which debug output will be used so we can set - flag_var_tracking if user has not specified it. */ - if (flag_var_tracking == AUTODETECT_FLAG_VAR_TRACKING) + flag_var_tracking, flag_rename_registers and flag_web if the user has + not specified them. */ + if (debug_info_level < DINFO_LEVEL_NORMAL + || debug_hooks->var_location == do_nothing_debug_hooks.var_location) { - /* User has not specified -f(no-)var-tracking so autodetect it. */ - flag_var_tracking - = (optimize >= 1 && debug_info_level >= DINFO_LEVEL_NORMAL - && debug_hooks->var_location != do_nothing_debug_hooks.var_location); + if (flag_var_tracking == 1) + { + if (debug_info_level < DINFO_LEVEL_NORMAL) + warning ("variable tracking requested, but useless unless " + "producing debug info"); + else + warning ("variable tracking requested, but not supported " + "by this debug format"); + } + flag_var_tracking = 0; } + if (flag_rename_registers == AUTODETECT_FLAG_VAR_TRACKING) + flag_rename_registers = default_debug_hooks->var_location + != do_nothing_debug_hooks.var_location; + + if (flag_web == AUTODETECT_FLAG_VAR_TRACKING) + flag_web = optimize >= 2 && (default_debug_hooks->var_location + != do_nothing_debug_hooks.var_location); + + if (flag_var_tracking == AUTODETECT_FLAG_VAR_TRACKING) + flag_var_tracking = optimize >= 1; + /* If auxiliary info generation is desired, open the output file. This goes in the same directory as the source file--unlike all the other output files. */