From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id EF0AB384B83F; Thu, 19 May 2022 12:47:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EF0AB384B83F MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-8397] Properly use opts in finish_options X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/releases/gcc-12 X-Git-Oldrev: 1e43783b3f3570f59bbe80fe38ba65049fa77a0a X-Git-Newrev: ad4fa189a7b6cbe183a4b1a99ca67888e68d7532 Message-Id: <20220519124708.EF0AB384B83F@sourceware.org> Date: Thu, 19 May 2022 12:47:08 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 May 2022 12:47:09 -0000 https://gcc.gnu.org/g:ad4fa189a7b6cbe183a4b1a99ca67888e68d7532 commit r12-8397-gad4fa189a7b6cbe183a4b1a99ca67888e68d7532 Author: Richard Biener 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 * 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; }