diff options
author | Richard Biener <rguenther@suse.de> | 2022-05-10 09:47:06 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2022-05-10 11:40:50 +0200 |
commit | d4694846102a9589558dd509ef70b7960063935d (patch) | |
tree | 0391f149be47e79a1216fafac117599bb06ba6ef /gcc | |
parent | 5b7a9751f55bcdb7d9a69345e02f62aaa7035d6b (diff) | |
download | gcc-d4694846102a9589558dd509ef70b7960063935d.zip gcc-d4694846102a9589558dd509ef70b7960063935d.tar.gz gcc-d4694846102a9589558dd509ef70b7960063935d.tar.bz2 |
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.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/flags.h | 4 | ||||
-rw-r--r-- | gcc/opts.cc | 67 |
2 files changed, 41 insertions, 30 deletions
diff --git a/gcc/flags.h b/gcc/flags.h index a9381cf..212e357 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 2ffbf42..a0baec9 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; } |