From 6ed760441a35e308dc434fac1f6a6589668ee928 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Tue, 12 Nov 2019 11:10:58 +0100 Subject: [PATCH] Use more SET_OPTION_IF_UNSET. 2019-11-12 Martin Liska * config/i386/i386-options.c (ix86_recompute_optlev_based_flags): Use SET_OPTION_IF_UNSET. (ix86_option_override_internal): Likewise. * opts.c (default_options_optimization): Likewise. (finish_options): Likewise. (enable_fdo_optimizations): Likewise. (common_handle_option): Likewise. 2019-11-12 Martin Liska * c-opts.c (c_common_post_options): Use SET_OPTION_IF_UNSET. 2019-11-12 Martin Liska * options.c (gfc_init_options): Use SET_OPTION_IF_UNSET. 2019-11-12 Martin Liska * go-lang.c (go_langhook_post_options): Use SET_OPTION_IF_UNSET. From-SVN: r278091 --- gcc/ChangeLog | 10 +++ gcc/c-family/ChangeLog | 5 ++ gcc/c-family/c-opts.c | 34 ++++----- gcc/config/i386/i386-options.c | 34 +++++---- gcc/fortran/ChangeLog | 5 ++ gcc/fortran/options.c | 4 +- gcc/go/ChangeLog | 5 ++ gcc/go/go-lang.c | 20 +++--- gcc/opts.c | 123 +++++++++++++-------------------- 9 files changed, 119 insertions(+), 121 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0c9da29b756..a56bdc130f2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2019-11-12 Martin Liska + + * config/i386/i386-options.c (ix86_recompute_optlev_based_flags): + Use SET_OPTION_IF_UNSET. + (ix86_option_override_internal): Likewise. + * opts.c (default_options_optimization): Likewise. + (finish_options): Likewise. + (enable_fdo_optimizations): Likewise. + (common_handle_option): Likewise. + 2019-11-12 Martin Liska * common/common-target.def: Remove option_validate_param and diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 3af2c111198..a174ff9047b 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2019-11-12 Martin Liska + + * c-opts.c (c_common_post_options): + Use SET_OPTION_IF_UNSET. + 2019-11-12 Maciej W. Rozycki Frederik Harwath diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index 75b69597be2..c913291c07c 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -828,9 +828,9 @@ c_common_post_options (const char **pfilename) /* C2X Annex F does not permit certain built-in functions to raise "inexact". */ - if (flag_isoc2x - && !global_options_set.x_flag_fp_int_builtin_inexact) - flag_fp_int_builtin_inexact = 0; + if (flag_isoc2x) + SET_OPTION_IF_UNSET (&global_options, &global_options_set, + flag_fp_int_builtin_inexact, 0); /* By default we use C99 inline semantics in GNU99 or C99 mode. C99 inline semantics are not supported in GNU89 or C89 mode. */ @@ -847,9 +847,9 @@ c_common_post_options (const char **pfilename) /* If -ffreestanding, -fno-hosted or -fno-builtin then disable pattern recognition. */ - if (!global_options_set.x_flag_tree_loop_distribute_patterns - && flag_no_builtin) - flag_tree_loop_distribute_patterns = 0; + if (flag_no_builtin) + SET_OPTION_IF_UNSET (&global_options, &global_options_set, + flag_tree_loop_distribute_patterns, 0); /* -Woverlength-strings is off by default, but is enabled by -Wpedantic. It is never enabled in C++, as the minimum limit is not normative @@ -918,16 +918,17 @@ c_common_post_options (const char **pfilename) && (cxx_dialect >= cxx11 || flag_isoc99)); /* -Wregister is enabled by default in C++17. */ - if (!global_options_set.x_warn_register) - warn_register = cxx_dialect >= cxx17; + SET_OPTION_IF_UNSET (&global_options, &global_options_set, warn_register, + cxx_dialect >= cxx17); /* -Wcomma-subscript is enabled by default in C++20. */ - if (!global_options_set.x_warn_comma_subscript) - warn_comma_subscript = (cxx_dialect >= cxx2a && warn_deprecated); + SET_OPTION_IF_UNSET (&global_options, &global_options_set, + warn_comma_subscript, + cxx_dialect >= cxx2a && warn_deprecated); /* -Wvolatile is enabled by default in C++20. */ - if (!global_options_set.x_warn_volatile) - warn_volatile = (cxx_dialect >= cxx2a && warn_deprecated); + SET_OPTION_IF_UNSET (&global_options, &global_options_set, warn_volatile, + cxx_dialect >= cxx2a && warn_deprecated); /* Declone C++ 'structors if -Os. */ if (flag_declone_ctor_dtor == -1) @@ -979,12 +980,13 @@ c_common_post_options (const char **pfilename) /* By default, enable the new inheriting constructor semantics along with ABI 11. New and old should coexist fine, but it is a change in what artificial symbols are generated. */ - if (!global_options_set.x_flag_new_inheriting_ctors) - flag_new_inheriting_ctors = abi_version_at_least (11); + SET_OPTION_IF_UNSET (&global_options, &global_options_set, + flag_new_inheriting_ctors, + abi_version_at_least (11)); /* For GCC 7, only enable DR150 resolution by default if -std=c++17. */ - if (!global_options_set.x_flag_new_ttp) - flag_new_ttp = (cxx_dialect >= cxx17); + SET_OPTION_IF_UNSET (&global_options, &global_options_set, flag_new_ttp, + cxx_dialect >= cxx17); if (cxx_dialect >= cxx11) { diff --git a/gcc/config/i386/i386-options.c b/gcc/config/i386/i386-options.c index c909f8ea1ed..b082228ebf2 100644 --- a/gcc/config/i386/i386-options.c +++ b/gcc/config/i386/i386-options.c @@ -1605,12 +1605,12 @@ ix86_recompute_optlev_based_flags (struct gcc_options *opts, in case they weren't overwritten by command line options. */ if (TARGET_64BIT_P (opts->x_ix86_isa_flags)) { - if (opts->x_optimize >= 1 && !opts_set->x_flag_omit_frame_pointer) - opts->x_flag_omit_frame_pointer = !USE_IX86_FRAME_POINTER; + if (opts->x_optimize >= 1) + SET_OPTION_IF_UNSET (opts, opts_set, flag_omit_frame_pointer, + !USE_IX86_FRAME_POINTER); if (opts->x_flag_asynchronous_unwind_tables - && !opts_set->x_flag_unwind_tables && TARGET_64BIT_MS_ABI) - opts->x_flag_unwind_tables = 1; + SET_OPTION_IF_UNSET (opts, opts_set, flag_unwind_tables, 1); if (opts->x_flag_asynchronous_unwind_tables == 2) opts->x_flag_unwind_tables = opts->x_flag_asynchronous_unwind_tables = 1; @@ -1619,9 +1619,9 @@ ix86_recompute_optlev_based_flags (struct gcc_options *opts, } else { - if (opts->x_optimize >= 1 && !opts_set->x_flag_omit_frame_pointer) - opts->x_flag_omit_frame_pointer - = !(USE_IX86_FRAME_POINTER || opts->x_optimize_size); + if (opts->x_optimize >= 1) + SET_OPTION_IF_UNSET (opts, opts_set, flag_omit_frame_pointer, + !(USE_IX86_FRAME_POINTER || opts->x_optimize_size)); if (opts->x_flag_asynchronous_unwind_tables == 2) opts->x_flag_asynchronous_unwind_tables = !USE_IX86_FRAME_POINTER; if (opts->x_flag_pcc_struct_return == 2) @@ -1821,8 +1821,7 @@ ix86_option_override_internal (bool main_args_p, opts->x_ix86_pmode = TARGET_LP64_P (opts->x_ix86_isa_flags) ? PMODE_DI : PMODE_SI; - if (!opts_set->x_ix86_abi) - opts->x_ix86_abi = DEFAULT_ABI; + SET_OPTION_IF_UNSET (opts, opts_set, ix86_abi, DEFAULT_ABI); if (opts->x_ix86_abi == MS_ABI && TARGET_X32_P (opts->x_ix86_isa_flags)) error ("%<-mabi=ms%> not supported with X32 ABI"); @@ -1843,8 +1842,8 @@ ix86_option_override_internal (bool main_args_p, /* For targets using ms ABI enable ms-extensions, if not explicit turned off. For non-ms ABI we turn off this option. */ - if (!opts_set->x_flag_ms_extensions) - opts->x_flag_ms_extensions = (MS_ABI == DEFAULT_ABI); + SET_OPTION_IF_UNSET (opts, opts_set, flag_ms_extensions, + (MS_ABI == DEFAULT_ABI)); if (opts_set->x_ix86_cmodel) { @@ -2367,8 +2366,8 @@ ix86_option_override_internal (bool main_args_p, ix86_default_align (opts); /* Provide default for -mbranch-cost= value. */ - if (!opts_set->x_ix86_branch_cost) - opts->x_ix86_branch_cost = ix86_tune_cost->branch_cost; + SET_OPTION_IF_UNSET (opts, opts_set, ix86_branch_cost, + ix86_tune_cost->branch_cost); if (TARGET_64BIT_P (opts->x_ix86_isa_flags)) { @@ -2474,8 +2473,8 @@ ix86_option_override_internal (bool main_args_p, } /* Set the default value for -mstackrealign. */ - if (!opts_set->x_ix86_force_align_arg_pointer) - opts->x_ix86_force_align_arg_pointer = STACK_REALIGN_DEFAULT; + SET_OPTION_IF_UNSET (opts, opts_set, ix86_force_align_arg_pointer, + STACK_REALIGN_DEFAULT); ix86_default_incoming_stack_boundary = PREFERRED_STACK_BOUNDARY; @@ -2863,9 +2862,8 @@ ix86_option_override_internal (bool main_args_p, /* PR86952: jump table usage with retpolines is slow. The PR provides some numbers about the slowness. */ - if (ix86_indirect_branch != indirect_branch_keep - && !opts_set->x_flag_jump_tables) - opts->x_flag_jump_tables = 0; + if (ix86_indirect_branch != indirect_branch_keep) + SET_OPTION_IF_UNSET (opts, opts_set, flag_jump_tables, 0); return true; } diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index d92a6ad2480..92a71a3c155 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2019-11-12 Martin Liska + + * options.c (gfc_init_options): + Use SET_OPTION_IF_UNSET. + 2019-11-12 Maciej W. Rozycki Frederik Harwath diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c index 305c57de85d..f7a5299c5e3 100644 --- a/gcc/fortran/options.c +++ b/gcc/fortran/options.c @@ -162,8 +162,8 @@ gfc_init_options (unsigned int decoded_options_count, /* ??? Wmissing-include-dirs is disabled by default in C/C++ but enabled by default in Fortran. Ideally, we should express this in .opt, but that is not supported yet. */ - if (!global_options_set.x_cpp_warn_missing_include_dirs) - global_options.x_cpp_warn_missing_include_dirs = 1; + SET_OPTION_IF_UNSET (&global_options, &global_options_set, + cpp_warn_missing_include_dirs, 1); set_dec_flags (0); diff --git a/gcc/go/ChangeLog b/gcc/go/ChangeLog index c62877fe8fb..eb1a03bab89 100644 --- a/gcc/go/ChangeLog +++ b/gcc/go/ChangeLog @@ -1,3 +1,8 @@ +2019-11-12 Martin Liska + + * go-lang.c (go_langhook_post_options): + Use SET_OPTION_IF_UNSET. + 2019-09-04 Ian Lance Taylor PR tree-optimization/91663 diff --git a/gcc/go/go-lang.c b/gcc/go/go-lang.c index 75d98933820..8766372b172 100644 --- a/gcc/go/go-lang.c +++ b/gcc/go/go-lang.c @@ -297,13 +297,13 @@ go_langhook_post_options (const char **pfilename ATTRIBUTE_UNUSED) flag_excess_precision = EXCESS_PRECISION_STANDARD; /* Tail call optimizations can confuse uses of runtime.Callers. */ - if (!global_options_set.x_flag_optimize_sibling_calls) - global_options.x_flag_optimize_sibling_calls = 0; + SET_OPTION_IF_UNSET (&global_options, &global_options_set, + flag_optimize_sibling_calls, 0); /* Partial inlining can confuses uses of runtime.Callers. See https://gcc.gnu.org/PR91663. */ - if (!global_options_set.x_flag_partial_inlining) - global_options.x_flag_partial_inlining = 0; + SET_OPTION_IF_UNSET (&global_options, &global_options_set, + flag_partial_inlining, 0); /* If the debug info level is still 1, as set in init_options, make sure that some debugging type is selected. */ @@ -312,18 +312,18 @@ go_langhook_post_options (const char **pfilename ATTRIBUTE_UNUSED) global_options.x_write_symbols = PREFERRED_DEBUGGING_TYPE; /* We turn on stack splitting if we can. */ - if (!global_options_set.x_flag_split_stack - && targetm_common.supports_split_stack (false, &global_options)) - global_options.x_flag_split_stack = 1; + if (targetm_common.supports_split_stack (false, &global_options)) + SET_OPTION_IF_UNSET (&global_options, &global_options_set, + flag_split_stack, 1); /* If stack splitting is turned on, and the user did not explicitly request function partitioning, turn off partitioning, as it confuses the linker when trying to handle partitioned split-stack code that calls a non-split-stack function. */ if (global_options.x_flag_split_stack - && global_options.x_flag_reorder_blocks_and_partition - && !global_options_set.x_flag_reorder_blocks_and_partition) - global_options.x_flag_reorder_blocks_and_partition = 0; + && global_options.x_flag_reorder_blocks_and_partition) + SET_OPTION_IF_UNSET (&global_options, &global_options_set, + flag_reorder_blocks_and_partition, 0); /* Returning false means that the backend should be used. */ return false; diff --git a/gcc/opts.c b/gcc/opts.c index 879b2100071..faf2eef082e 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -641,9 +641,8 @@ default_options_optimization (struct gcc_options *opts, /* -O2 param settings. */ opt2 = (opts->x_optimize >= 2); - if (openacc_mode - && !opts_set->x_flag_ipa_pta) - opts->x_flag_ipa_pta = true; + if (openacc_mode) + SET_OPTION_IF_UNSET (opts, opts_set, flag_ipa_pta, true); /* Track fields in field-sensitive alias analysis. */ if (opt2) @@ -1064,13 +1063,11 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set, code that calls a non-split-stack functions. But if partitioning was turned on explicitly just hope for the best. */ if (opts->x_flag_split_stack - && opts->x_flag_reorder_blocks_and_partition - && !opts_set->x_flag_reorder_blocks_and_partition) - opts->x_flag_reorder_blocks_and_partition = 0; + && opts->x_flag_reorder_blocks_and_partition) + SET_OPTION_IF_UNSET (opts, opts_set, flag_reorder_blocks_and_partition, 0); - if (opts->x_flag_reorder_blocks_and_partition - && !opts_set->x_flag_reorder_functions) - opts->x_flag_reorder_functions = 1; + if (opts->x_flag_reorder_blocks_and_partition) + SET_OPTION_IF_UNSET (opts, opts_set, flag_reorder_functions, 1); /* The -gsplit-dwarf option requires -ggnu-pubnames. */ if (opts->x_dwarf_split_debug_info) @@ -1127,9 +1124,9 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set, /* Enable -fsanitize-address-use-after-scope if address sanitizer is enabled. */ - if ((opts->x_flag_sanitize & SANITIZE_USER_ADDRESS) - && !opts_set->x_flag_sanitize_address_use_after_scope) - opts->x_flag_sanitize_address_use_after_scope = true; + if (opts->x_flag_sanitize & SANITIZE_USER_ADDRESS) + SET_OPTION_IF_UNSET (opts, opts_set, flag_sanitize_address_use_after_scope, + true); /* Force -fstack-reuse=none in case -fsanitize-address-use-after-scope is enabled. */ @@ -1670,52 +1667,34 @@ enable_fdo_optimizations (struct gcc_options *opts, struct gcc_options *opts_set, int value) { - if (!opts_set->x_flag_branch_probabilities) - opts->x_flag_branch_probabilities = value; - if (!opts_set->x_flag_profile_values) - opts->x_flag_profile_values = value; - if (!opts_set->x_flag_unroll_loops) - opts->x_flag_unroll_loops = value; - if (!opts_set->x_flag_peel_loops) - opts->x_flag_peel_loops = value; - if (!opts_set->x_flag_tracer) - opts->x_flag_tracer = value; - if (!opts_set->x_flag_value_profile_transformations) - opts->x_flag_value_profile_transformations = value; - if (!opts_set->x_flag_inline_functions) - opts->x_flag_inline_functions = value; - if (!opts_set->x_flag_ipa_cp) - opts->x_flag_ipa_cp = value; - if (!opts_set->x_flag_ipa_cp_clone - && value && opts->x_flag_ipa_cp) - opts->x_flag_ipa_cp_clone = value; - if (!opts_set->x_flag_ipa_bit_cp - && value && opts->x_flag_ipa_cp) - opts->x_flag_ipa_bit_cp = value; - if (!opts_set->x_flag_predictive_commoning) - opts->x_flag_predictive_commoning = value; - if (!opts_set->x_flag_split_loops) - opts->x_flag_split_loops = value; - if (!opts_set->x_flag_unswitch_loops) - opts->x_flag_unswitch_loops = value; - if (!opts_set->x_flag_gcse_after_reload) - opts->x_flag_gcse_after_reload = value; - if (!opts_set->x_flag_tree_loop_vectorize) - opts->x_flag_tree_loop_vectorize = value; - if (!opts_set->x_flag_tree_slp_vectorize) - opts->x_flag_tree_slp_vectorize = value; - if (!opts_set->x_flag_version_loops_for_strides) - opts->x_flag_version_loops_for_strides = value; - if (!opts_set->x_flag_vect_cost_model) - opts->x_flag_vect_cost_model = VECT_COST_MODEL_DYNAMIC; - if (!opts_set->x_flag_tree_loop_distribute_patterns) - opts->x_flag_tree_loop_distribute_patterns = value; - if (!opts_set->x_flag_loop_interchange) - opts->x_flag_loop_interchange = value; - if (!opts_set->x_flag_unroll_jam) - opts->x_flag_unroll_jam = value; - if (!opts_set->x_flag_tree_loop_distribution) - opts->x_flag_tree_loop_distribution = value; + SET_OPTION_IF_UNSET (opts, opts_set, flag_branch_probabilities, value); + SET_OPTION_IF_UNSET (opts, opts_set, flag_profile_values, value); + SET_OPTION_IF_UNSET (opts, opts_set, flag_unroll_loops, value); + SET_OPTION_IF_UNSET (opts, opts_set, flag_peel_loops, value); + SET_OPTION_IF_UNSET (opts, opts_set, flag_tracer, value); + SET_OPTION_IF_UNSET (opts, opts_set, flag_value_profile_transformations, + value); + SET_OPTION_IF_UNSET (opts, opts_set, flag_inline_functions, value); + SET_OPTION_IF_UNSET (opts, opts_set, flag_ipa_cp, value); + if (value) + { + SET_OPTION_IF_UNSET (opts, opts_set, flag_ipa_cp_clone, 1); + SET_OPTION_IF_UNSET (opts, opts_set, flag_ipa_bit_cp, 1); + } + SET_OPTION_IF_UNSET (opts, opts_set, flag_predictive_commoning, value); + SET_OPTION_IF_UNSET (opts, opts_set, flag_split_loops, value); + SET_OPTION_IF_UNSET (opts, opts_set, flag_unswitch_loops, value); + SET_OPTION_IF_UNSET (opts, opts_set, flag_gcse_after_reload, value); + SET_OPTION_IF_UNSET (opts, opts_set, flag_tree_loop_vectorize, value); + SET_OPTION_IF_UNSET (opts, opts_set, flag_tree_slp_vectorize, value); + SET_OPTION_IF_UNSET (opts, opts_set, flag_version_loops_for_strides, value); + SET_OPTION_IF_UNSET (opts, opts_set, flag_vect_cost_model, + VECT_COST_MODEL_DYNAMIC); + SET_OPTION_IF_UNSET (opts, opts_set, flag_tree_loop_distribute_patterns, + value); + SET_OPTION_IF_UNSET (opts, opts_set, flag_loop_interchange, value); + SET_OPTION_IF_UNSET (opts, opts_set, flag_unroll_jam, value); + SET_OPTION_IF_UNSET (opts, opts_set, flag_tree_loop_distribution, value); } /* -f{,no-}sanitize{,-recover}= suboptions. */ @@ -2531,13 +2510,13 @@ common_handle_option (struct gcc_options *opts, /* FALLTHRU */ case OPT_fprofile_use: enable_fdo_optimizations (opts, opts_set, value); - if (!opts_set->x_flag_profile_reorder_functions) - opts->x_flag_profile_reorder_functions = value; + SET_OPTION_IF_UNSET (opts, opts_set, flag_profile_reorder_functions, + value); /* Indirect call profiling should do all useful transformations speculative devirtualization does. */ - if (!opts_set->x_flag_devirtualize_speculatively - && opts->x_flag_value_profile_transformations) - opts->x_flag_devirtualize_speculatively = false; + if (opts->x_flag_value_profile_transformations) + SET_OPTION_IF_UNSET (opts, opts_set, flag_devirtualize_speculatively, + false); break; case OPT_fauto_profile_: @@ -2548,8 +2527,7 @@ common_handle_option (struct gcc_options *opts, /* FALLTHRU */ case OPT_fauto_profile: enable_fdo_optimizations (opts, opts_set, value); - if (!opts_set->x_flag_profile_correction) - opts->x_flag_profile_correction = value; + SET_OPTION_IF_UNSET (opts, opts_set, flag_profile_correction, value); SET_OPTION_IF_UNSET (opts, opts_set, param_early_inliner_max_iterations, 10); break; @@ -2560,19 +2538,14 @@ common_handle_option (struct gcc_options *opts, /* No break here - do -fprofile-generate processing. */ /* FALLTHRU */ case OPT_fprofile_generate: - if (!opts_set->x_profile_arc_flag) - opts->x_profile_arc_flag = value; - if (!opts_set->x_flag_profile_values) - opts->x_flag_profile_values = value; - if (!opts_set->x_flag_inline_functions) - opts->x_flag_inline_functions = value; - if (!opts_set->x_flag_ipa_bit_cp) - opts->x_flag_ipa_bit_cp = value; + SET_OPTION_IF_UNSET (opts, opts_set, profile_arc_flag, value); + SET_OPTION_IF_UNSET (opts, opts_set, flag_profile_values, value); + SET_OPTION_IF_UNSET (opts, opts_set, flag_inline_functions, value); + SET_OPTION_IF_UNSET (opts, opts_set, flag_ipa_bit_cp, value); /* FIXME: Instrumentation we insert makes ipa-reference bitmaps quadratic. Disable the pass until better memory representation is done. */ - if (!opts_set->x_flag_ipa_reference) - opts->x_flag_ipa_reference = false; + SET_OPTION_IF_UNSET (opts, opts_set, flag_ipa_reference, false); break; case OPT_fpatchable_function_entry_: -- 2.30.2