This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Enable -frename-registers and -fweb at lower -O levels, take 2


> > It is as wrong as enabling -frename-registers
> > unconditionally at -O3.
>
> No, it isn't.

Fine.  I actually wanted some discussion to happen with that patch so that
I would understand other people's views.

This take enables -fweb at -O2 and -frename-registers at -O1 if variable
tracking is available for the target'sdefault debugging information format.
It also extends the chunk that decides whether to activate variable
tracking, so that a warning is given if -fvar-tracking is set but the
current debug format does not support it.

Ok for mainline?

Paolo

2004-04-04  Paolo Bonzini  <bonzini@gnu.org>

	* 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.

Index: opts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/opts.c,v
retrieving revision 1.62
diff -u -p -r1.62 opts.c
--- opts.c	14 Mar 2004 22:26:06 -0000	1.62
+++ opts.c	7 Apr 2004 07:47:31 -0000
@@ -571,9 +571,7 @@ decode_options (unsigned int argc, const
   if (optimize >= 3)
     {
       flag_inline_functions = 1;
-      flag_rename_registers = 1;
       flag_unswitch_loops = 1;
-      flag_web = 1;
       flag_gcse_after_reload = 1;
     }
 
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.889
diff -u -p -r1.889 toplev.c
--- toplev.c	29 Mar 2004 23:00:27 -0000	1.889
+++ toplev.c	7 Apr 2004 07:47:34 -0000
@@ -138,6 +138,10 @@ static const char **save_argv;
 
 const char *main_input_filename;
 
+/* Used to enable -fvar-tracking and -frename-registers according to
+   optimize, debug_info_level and 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;
@@ -253,9 +261,10 @@ int flag_reorder_blocks = 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
@@ -482,7 +491,7 @@ int flag_syntax_only = 0;
 
 /* Nonzero means performs web construction pass.  */
 
-int flag_web;
+int flag_web = AUTODETECT_FLAG_VAR_TRACKING;
 
 /* Nonzero means perform loop optimizer.  */
 
@@ -795,8 +804,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.
@@ -2324,6 +2331,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)
@@ -2351,14 +2382,33 @@ 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)
-    {
-      /* 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);
+     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)
+    {
+      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
Index: doc/invoke.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/invoke.texi,v
retrieving revision 1.438
diff -u -p -r1.438 invoke.texi
--- doc/invoke.texi	25 Mar 2004 17:43:24 -0000	1.438
+++ doc/invoke.texi	7 Apr 2004 07:47:42 -0000
@@ -4328,11 +4328,14 @@ Enabled at levels @option{-O2}, @option{
 @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
@@ -4343,7 +4346,9 @@ passes, such as CSE, loop optimizer and 
 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]