From 8cc5fcaf1f04f8c7323181a53f05b34ed28a0f1a Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Tue, 12 Nov 2019 11:09:57 +0100 Subject: [PATCH] Remove last leftover usage of params* files. 2019-11-12 Martin Liska * common.opt: Remove param_values. * config/i386/i386-options.c (ix86_valid_target_attribute_p): Remove finalize_options_struct. * gcc.c (driver::decode_argv): Do not call global_init_params and finish_params. (driver::finalize): Do not call params_c_finalize and finalize_options_struct. * opt-suggestions.c (option_proposer::get_completions): Remove special casing of params. (option_proposer::find_param_completions): Remove. (test_completion_partial_match): Update expected output. * opt-suggestions.h: Remove find_param_completions. * opts-common.c (add_misspelling_candidates): Add --param with a space. * opts.c (handle_param): Remove. (init_options_struct):. Remove init_options_struct and similar calls. (finalize_options_struct): Remove. (common_handle_option): Use SET_OPTION_IF_UNSET. * opts.h (finalize_options_struct): Remove. * toplev.c (general_init): Do not call global_init_params. (toplev::finalize): Do not call params_c_finalize and finalize_options_struct. From-SVN: r278087 --- gcc/ChangeLog | 26 +++++++++++++ gcc/common.opt | 3 -- gcc/config/i386/i386-options.c | 2 - gcc/gcc.c | 8 ---- gcc/opt-suggestions.c | 58 ++++++--------------------- gcc/opt-suggestions.h | 5 --- gcc/opts-common.c | 11 ++++++ gcc/opts.c | 71 ++-------------------------------- gcc/opts.h | 1 - gcc/toplev.c | 8 ---- 10 files changed, 53 insertions(+), 140 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ef517764675..1be218cbf5c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,29 @@ +2019-11-12 Martin Liska + + * common.opt: Remove param_values. + * config/i386/i386-options.c (ix86_valid_target_attribute_p): + Remove finalize_options_struct. + * gcc.c (driver::decode_argv): Do not call global_init_params + and finish_params. + (driver::finalize): Do not call params_c_finalize + and finalize_options_struct. + * opt-suggestions.c (option_proposer::get_completions): Remove + special casing of params. + (option_proposer::find_param_completions): Remove. + (test_completion_partial_match): Update expected output. + * opt-suggestions.h: Remove find_param_completions. + * opts-common.c (add_misspelling_candidates): Add + --param with a space. + * opts.c (handle_param): Remove. + (init_options_struct):. Remove init_options_struct and + similar calls. + (finalize_options_struct): Remove. + (common_handle_option): Use SET_OPTION_IF_UNSET. + * opts.h (finalize_options_struct): Remove. + * toplev.c (general_init): Do not call global_init_params. + (toplev::finalize): Do not call params_c_finalize and + finalize_options_struct. + 2019-11-12 Martin Liska * Makefile.in: Remove PARAMS_H and params.list diff --git a/gcc/common.opt b/gcc/common.opt index 8c6acabb1fc..26b6c2ce9e1 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -63,9 +63,6 @@ int flag_complex_method = 1 Variable bool flag_warn_unused_result = false -Variable -int *param_values - ; Nonzero if we should write GIMPLE bytecode for link-time optimization. Variable int flag_generate_lto diff --git a/gcc/config/i386/i386-options.c b/gcc/config/i386/i386-options.c index 1e3280d1bb9..c909f8ea1ed 100644 --- a/gcc/config/i386/i386-options.c +++ b/gcc/config/i386/i386-options.c @@ -1340,8 +1340,6 @@ ix86_valid_target_attribute_p (tree fndecl, DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl) = new_optimize; } - finalize_options_struct (&func_options); - return ret; } diff --git a/gcc/gcc.c b/gcc/gcc.c index 159ffe7cb53..539ded01ce6 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -7422,10 +7422,6 @@ driver::expand_at_files (int *argc, char ***argv) const void driver::decode_argv (int argc, const char **argv) { - /* Register the language-independent parameters. */ - global_init_params (); - finish_params (); - init_opts_obstack (); init_options_struct (&global_options, &global_options_set); @@ -10113,7 +10109,6 @@ void driver::finalize () { env.restore (); - params_c_finalize (); diagnostic_finish (global_dc); is_cpp_driver = 0; @@ -10134,9 +10129,6 @@ driver::finalize () spec_machine = DEFAULT_TARGET_MACHINE; greatest_status = 1; - finalize_options_struct (&global_options); - finalize_options_struct (&global_options_set); - obstack_free (&obstack, NULL); obstack_free (&opts_obstack, NULL); /* in opts.c */ obstack_free (&collect_obstack, NULL); diff --git a/gcc/opt-suggestions.c b/gcc/opt-suggestions.c index 609e60bd20a..01ce331eb0e 100644 --- a/gcc/opt-suggestions.c +++ b/gcc/opt-suggestions.c @@ -64,32 +64,17 @@ option_proposer::get_completions (const char *option_prefix, size_t length = strlen (option_prefix); - /* Handle OPTION_PREFIX starting with "-param". */ - const char *prefix = "-param"; - if (length >= strlen (prefix) - && strstr (option_prefix, prefix) == option_prefix) - { - /* We support both '-param-xyz=123' and '-param xyz=123' */ - option_prefix += strlen (prefix); - char separator = option_prefix[0]; - option_prefix++; - if (separator == ' ' || separator == '=') - find_param_completions (separator, option_prefix, results); - } - else - { - /* Lazily populate m_option_suggestions. */ - if (!m_option_suggestions) - build_option_suggestions (option_prefix); - gcc_assert (m_option_suggestions); + /* Lazily populate m_option_suggestions. */ + if (!m_option_suggestions) + build_option_suggestions (option_prefix); + gcc_assert (m_option_suggestions); - for (unsigned i = 0; i < m_option_suggestions->length (); i++) - { - char *candidate = (*m_option_suggestions)[i]; - if (strlen (candidate) >= length - && strstr (candidate, option_prefix) == candidate) - results.safe_push (concat ("-", candidate, NULL)); - } + for (unsigned i = 0; i < m_option_suggestions->length (); i++) + { + char *candidate = (*m_option_suggestions)[i]; + if (strlen (candidate) >= length + && strstr (candidate, option_prefix) == candidate) + results.safe_push (concat ("-", candidate, NULL)); } } @@ -212,25 +197,6 @@ option_proposer::build_option_suggestions (const char *prefix) } } -/* Find parameter completions for --param format with SEPARATOR. - Again, save the completions into results. */ - -void -option_proposer::find_param_completions (const char separator, - const char *param_prefix, - auto_string_vec &results) -{ - char separator_str[] = {separator, '\0'}; - size_t length = strlen (param_prefix); - for (unsigned i = 0; i < get_num_compiler_params (); ++i) - { - const char *candidate = compiler_params[i].option; - if (strlen (candidate) >= length - && strstr (candidate, param_prefix) == candidate) - results.safe_push (concat ("--param", separator_str, candidate, NULL)); - } -} - #if CHECKING_P namespace selftest { @@ -400,9 +366,9 @@ test_completion_partial_match (option_proposer &proposer) ASSERT_TRUE (in_completion_p (proposer, "-fipa-icf", "-fipa-icf-functions")); ASSERT_TRUE (in_completion_p (proposer, "-fipa-icf", "-fipa-icf")); ASSERT_TRUE (in_completion_p (proposer, "--param=", - "--param=max-vartrack-reverse-op-size")); + "--param=max-vartrack-reverse-op-size=")); ASSERT_TRUE (in_completion_p (proposer, "--param ", - "--param max-vartrack-reverse-op-size")); + "--param max-vartrack-reverse-op-size=")); ASSERT_FALSE (in_completion_p (proposer, "-fipa-icf", "-fipa")); ASSERT_FALSE (in_completion_p (proposer, "-fipa-icf-functions", "-fipa-icf")); diff --git a/gcc/opt-suggestions.h b/gcc/opt-suggestions.h index 8d24833c0ed..93f65bea3bb 100644 --- a/gcc/opt-suggestions.h +++ b/gcc/opt-suggestions.h @@ -63,11 +63,6 @@ private: it's set to NULL. */ void build_option_suggestions (const char *prefix); - /* Find parameter completions for --param format with SEPARATOR. - Again, save the completions into results. */ - void find_param_completions (const char separator, const char *param_prefix, - auto_string_vec &results); - private: /* Cache with all suggestions. */ auto_string_vec *m_option_suggestions; diff --git a/gcc/opts-common.c b/gcc/opts-common.c index d55dc93e165..51e08d4f44c 100644 --- a/gcc/opts-common.c +++ b/gcc/opts-common.c @@ -510,6 +510,17 @@ add_misspelling_candidates (auto_vec *candidates, candidates->safe_push (alternative); } } + + /* For all params (e.g. --param=key=value), + include also '--param key=value'. */ + const char *prefix = "--param="; + if (strstr (opt_text, prefix) == opt_text) + { + char *param = xstrdup (opt_text + 1); + gcc_assert (param[6] == '='); + param[6] = ' '; + candidates->safe_push (param); + } } /* Decode the switch beginning at ARGV for the language indicated by diff --git a/gcc/opts.c b/gcc/opts.c index f9c6f20c025..879b2100071 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -188,9 +188,6 @@ static const char use_diagnosed_msg[] = N_("Uses of this option are diagnosed.") typedef char *char_p; /* For DEF_VEC_P. */ -static void handle_param (struct gcc_options *opts, - struct gcc_options *opts_set, location_t loc, - const char *carg); static void set_debug_level (enum debug_info_type type, int extended, const char *arg, struct gcc_options *opts, struct gcc_options *opts_set, @@ -283,8 +280,6 @@ init_opts_obstack (void) void init_options_struct (struct gcc_options *opts, struct gcc_options *opts_set) { - size_t num_params = get_num_compiler_params (); - /* Ensure that opts_obstack has already been initialized by the time that we initialize any gcc_options instances (PR jit/68446). */ gcc_assert (opts_obstack.chunk_size > 0); @@ -294,13 +289,6 @@ init_options_struct (struct gcc_options *opts, struct gcc_options *opts_set) if (opts_set) memset (opts_set, 0, sizeof (*opts_set)); - opts->x_param_values = XNEWVEC (int, num_params); - - if (opts_set) - opts_set->x_param_values = XCNEWVEC (int, num_params); - - init_param_values (opts->x_param_values); - /* Initialize whether `char' is signed. */ opts->x_flag_signed_char = DEFAULT_SIGNED_CHAR; /* Set this to a special "uninitialized" value. The actual default @@ -318,14 +306,6 @@ init_options_struct (struct gcc_options *opts, struct gcc_options *opts_set) targetm_common.option_init_struct (opts); } -/* Release any allocations owned by OPTS. */ - -void -finalize_options_struct (struct gcc_options *opts) -{ - XDELETEVEC (opts->x_param_values); -} - /* If indicated by the optimization level LEVEL (-Os if SIZE is set, -Ofast if FAST is set, -Og if DEBUG is set), apply the option DEFAULT_OPT to OPTS and OPTS_SET, diagnostic context DC, location LOC, with language @@ -2465,10 +2445,10 @@ common_handle_option (struct gcc_options *opts, break; case OPT_finline_limit_: - set_param_value ("max-inline-insns-single", value / 2, - opts->x_param_values, opts_set->x_param_values); - set_param_value ("max-inline-insns-auto", value / 2, - opts->x_param_values, opts_set->x_param_values); + SET_OPTION_IF_UNSET (opts, opts_set, param_max_inline_insns_single, + value / 2); + SET_OPTION_IF_UNSET (opts, opts_set, param_max_inline_insns_auto, + value / 2); break; case OPT_finstrument_functions_exclude_function_list_: @@ -2836,49 +2816,6 @@ common_handle_option (struct gcc_options *opts, return true; } -/* Handle --param NAME=VALUE. */ -static void -handle_param (struct gcc_options *opts, struct gcc_options *opts_set, - location_t loc, const char *carg) -{ - char *equal, *arg; - int value; - - arg = xstrdup (carg); - equal = strchr (arg, '='); - if (!equal) - error_at (loc, "%s: %qs arguments should be of the form NAME=VALUE", - arg, "--param"); - else - { - *equal = '\0'; - - enum compiler_param index; - if (!find_param (arg, &index)) - { - const char *suggestion = find_param_fuzzy (arg); - if (suggestion) - error_at (loc, "invalid %qs name %qs; did you mean %qs?", - "--param", arg, suggestion); - else - error_at (loc, "invalid %qs name %qs", "--param", arg); - } - else - { - if (!param_string_value_p (index, equal + 1, &value)) - value = integral_argument (equal + 1); - - if (value == -1) - error_at (loc, "invalid %qs value %qs", "--param", equal + 1); - else - set_param_value (arg, value, - opts->x_param_values, opts_set->x_param_values); - } - } - - free (arg); -} - /* Used to set the level of strict aliasing warnings in OPTS, when no level is specified (i.e., when -Wstrict-aliasing, and not -Wstrict-aliasing=level was given). diff --git a/gcc/opts.h b/gcc/opts.h index 0de8e4269db..b6173986b20 100644 --- a/gcc/opts.h +++ b/gcc/opts.h @@ -345,7 +345,6 @@ extern void init_options_once (void); extern void init_options_struct (struct gcc_options *opts, struct gcc_options *opts_set); extern void init_opts_obstack (void); -extern void finalize_options_struct (struct gcc_options *opts); extern void decode_cmdline_options_to_array_default_mask (unsigned int argc, const char **argv, struct cl_decoded_option **decoded_options, diff --git a/gcc/toplev.c b/gcc/toplev.c index 513e4e066b7..d4583bac66c 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -1240,9 +1240,6 @@ general_init (const char *argv0, bool init_signals) /* Initialize register usage now so switches may override. */ init_reg_sets (); - /* Register the language-independent parameters. */ - global_init_params (); - /* This must be done after global_init_params but before argument processing. */ init_ggc_heuristics (); @@ -1262,7 +1259,6 @@ general_init (const char *argv0, bool init_signals) statistics_early_init (); debuginfo_early_init (); - finish_params (); } /* Return true if the current target supports -fsection-anchors. */ @@ -2468,10 +2464,6 @@ toplev::finalize (void) gcse_c_finalize (); ipa_cp_c_finalize (); ira_costs_c_finalize (); - params_c_finalize (); - - finalize_options_struct (&global_options); - finalize_options_struct (&global_options_set); /* save_decoded_options uses opts_obstack, so these must be cleaned up together. */ -- 2.30.2