public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-8397] Properly use opts in finish_options
@ 2022-05-19 12:47 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2022-05-19 12:47 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:ad4fa189a7b6cbe183a4b1a99ca67888e68d7532

commit r12-8397-gad4fa189a7b6cbe183a4b1a99ca67888e68d7532
Author: Richard Biener <rguenther@suse.de>
Date:   Tue May 10 09:47:06 2022 +0200

    Properly use opts in finish_options
    
    When code was moved from process_options to finish_options it
    was not properly adjusted to look at and alter the opts set
    passed to the function but continued to modify the global options
    set.  The following rectifies this and makes sure the same
    mistake isn't repeated by poisoning global_options{,_set}.
    
    2022-05-10  Richard Biener  <rguenther@suse.de>
    
            * flags.h (dwarf_debuginfo_p): Add opts argument, guard
            API with !GENERATOR_FILE.
            * opts.cc (global_options): Poison.
            (global_options_set): Likewise.
            (finish_options): Refer to options via opts.
    
    (cherry picked from commit d4694846102a9589558dd509ef70b7960063935d)

Diff:
---
 gcc/flags.h |  4 +++-
 gcc/opts.cc | 67 +++++++++++++++++++++++++++++++++++--------------------------
 2 files changed, 41 insertions(+), 30 deletions(-)

diff --git a/gcc/flags.h b/gcc/flags.h
index a9381cf93f2..212e357a0fd 100644
--- a/gcc/flags.h
+++ b/gcc/flags.h
@@ -40,6 +40,7 @@ unsigned int debug_set_count (uint32_t w_symbols);
 
 const char * debug_set_names (uint32_t w_symbols);
 
+#ifndef GENERATOR_FILE
 /* Return true iff BTF debug info is enabled.  */
 
 extern bool btf_debuginfo_p ();
@@ -54,12 +55,13 @@ extern bool ctf_debuginfo_p ();
 
 /* Return true iff DWARF2 debug info is enabled.  */
 
-extern bool dwarf_debuginfo_p ();
+extern bool dwarf_debuginfo_p (struct gcc_options *opts = &global_options);
 
 /* Return true iff the debug info format is to be generated based on DWARF
    DIEs (like CTF and BTF debug info formats).  */
 
 extern bool dwarf_based_debuginfo_p ();
+#endif
 
 extern void strip_off_ending (char *, int);
 extern int base_of_path (const char *path, const char **base_out);
diff --git a/gcc/opts.cc b/gcc/opts.cc
index 2ffbf429b7b..a0baec98092 100644
--- a/gcc/opts.cc
+++ b/gcc/opts.cc
@@ -157,9 +157,9 @@ ctf_debuginfo_p ()
 /* Return TRUE iff dwarf2 debug info is enabled.  */
 
 bool
-dwarf_debuginfo_p ()
+dwarf_debuginfo_p (struct gcc_options *opts)
 {
-  return (write_symbols & DWARF2_DEBUG);
+  return (opts->x_write_symbols & DWARF2_DEBUG);
 }
 
 /* Return true iff the debug info format is to be generated based on DWARF
@@ -171,6 +171,11 @@ bool dwarf_based_debuginfo_p ()
 	  || (write_symbols & BTF_DEBUG));
 }
 
+/* All flag uses below need to explicitely reference the option sets
+   to operate on.  */
+#define global_options DO_NOT_USE
+#define global_options_set DO_NOT_USE
+
 /* Parse the -femit-struct-debug-detailed option value
    and set the flag variables. */
 
@@ -1305,57 +1310,61 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set,
     SET_OPTION_IF_UNSET (opts, opts_set, flag_vect_cost_model,
 			 VECT_COST_MODEL_CHEAP);
 
-  if (flag_gtoggle)
+  if (opts->x_flag_gtoggle)
     {
       /* Make sure to process -gtoggle only once.  */
-      flag_gtoggle = false;
-      if (debug_info_level == DINFO_LEVEL_NONE)
+      opts->x_flag_gtoggle = false;
+      if (opts->x_debug_info_level == DINFO_LEVEL_NONE)
 	{
-	  debug_info_level = DINFO_LEVEL_NORMAL;
+	  opts->x_debug_info_level = DINFO_LEVEL_NORMAL;
 
-	  if (write_symbols == NO_DEBUG)
-	    write_symbols = PREFERRED_DEBUGGING_TYPE;
+	  if (opts->x_write_symbols == NO_DEBUG)
+	    opts->x_write_symbols = PREFERRED_DEBUGGING_TYPE;
 	}
       else
-	debug_info_level = DINFO_LEVEL_NONE;
+	opts->x_debug_info_level = DINFO_LEVEL_NONE;
     }
 
   if (!opts_set->x_debug_nonbind_markers_p)
-    debug_nonbind_markers_p
-      = (optimize
-	 && debug_info_level >= DINFO_LEVEL_NORMAL
-	 && dwarf_debuginfo_p ()
-	 && !(flag_selective_scheduling || flag_selective_scheduling2));
+    opts->x_debug_nonbind_markers_p
+      = (opts->x_optimize
+	 && opts->x_debug_info_level >= DINFO_LEVEL_NORMAL
+	 && dwarf_debuginfo_p (opts)
+	 && !(opts->x_flag_selective_scheduling
+	      || opts->x_flag_selective_scheduling2));
 
   /* Note -fvar-tracking is enabled automatically with OPT_LEVELS_1_PLUS and
      so we need to drop it if we are called from optimize attribute.  */
-  if (debug_info_level < DINFO_LEVEL_NORMAL)
-    flag_var_tracking = false;
+  if (opts->x_debug_info_level < DINFO_LEVEL_NORMAL)
+    opts->x_flag_var_tracking = false;
 
   /* One could use EnabledBy, but it would lead to a circular dependency.  */
   if (!opts_set->x_flag_var_tracking_uninit)
-     flag_var_tracking_uninit = flag_var_tracking;
+    opts->x_flag_var_tracking_uninit = opts->x_flag_var_tracking;
 
   if (!opts_set->x_flag_var_tracking_assignments)
-    flag_var_tracking_assignments
-      = (flag_var_tracking
-	 && !(flag_selective_scheduling || flag_selective_scheduling2));
+    opts->x_flag_var_tracking_assignments
+      = (opts->x_flag_var_tracking
+	 && !(opts->x_flag_selective_scheduling
+	      || opts->x_flag_selective_scheduling2));
 
-  if (flag_var_tracking_assignments_toggle)
-    flag_var_tracking_assignments = !flag_var_tracking_assignments;
+  if (opts->x_flag_var_tracking_assignments_toggle)
+    opts->x_flag_var_tracking_assignments
+      = !opts->x_flag_var_tracking_assignments;
 
-  if (flag_var_tracking_assignments && !flag_var_tracking)
-    flag_var_tracking = flag_var_tracking_assignments = -1;
+  if (opts->x_flag_var_tracking_assignments && !opts->x_flag_var_tracking)
+    opts->x_flag_var_tracking = opts->x_flag_var_tracking_assignments = -1;
 
-  if (flag_var_tracking_assignments
-      && (flag_selective_scheduling || flag_selective_scheduling2))
+  if (opts->x_flag_var_tracking_assignments
+      && (opts->x_flag_selective_scheduling
+	  || opts->x_flag_selective_scheduling2))
     warning_at (loc, 0,
 		"var-tracking-assignments changes selective scheduling");
 
-  if (flag_syntax_only)
+  if (opts->x_flag_syntax_only)
     {
-      write_symbols = NO_DEBUG;
-      profile_flag = 0;
+      opts->x_write_symbols = NO_DEBUG;
+      opts->x_profile_flag = 0;
     }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-19 12:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-19 12:47 [gcc r12-8397] Properly use opts in finish_options Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).