diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-09-19 09:29:57 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-09-19 09:29:57 +0000 |
commit | 9b0d2865e2fe868519d9166886fbb3695ad0e9bd (patch) | |
tree | 4dffe7fee5a1a31e84a3c34642c6d71e05ef8e5c /gcc/opts.c | |
parent | 7b6f8db47b0b82cb4fd69bf111cce49a5aa5d192 (diff) | |
download | gcc-9b0d2865e2fe868519d9166886fbb3695ad0e9bd.tar.gz |
2012-09-19 Richard Guenther <rguenther@suse.de>
PR other/53316
* common.opt (optimize_debug): New variable.
(Og): New optimization level.
* doc/invoke.texi (Og): Document.
* opts.c (maybe_default_option): Add debug parameter.
(maybe_default_options): Likewise.
(default_options_optimization): Handle -Og.
(common_handle_option): Likewise.
* passes.c (gate_all_optimizations): Do not run with -Og.
(gate_all_optimizations_g): New gate, run with -Og.
(pass_all_optimizations_g): New container pass, run with -Og.
(init_optimization_passes): Schedule pass_all_optimizations_g
alongside pass_all_optimizations.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@191464 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/opts.c')
-rw-r--r-- | gcc/opts.c | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/gcc/opts.c b/gcc/opts.c index 0ddb1a0e582..5ab9ad9c42d 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -314,15 +314,15 @@ init_options_struct (struct gcc_options *opts, struct gcc_options *opts_set) } /* If indicated by the optimization level LEVEL (-Os if SIZE is set, - -Ofast if FAST is set), apply the option DEFAULT_OPT to OPTS and - OPTS_SET, diagnostic context DC, location LOC, with language mask - LANG_MASK and option handlers HANDLERS. */ + -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 + mask LANG_MASK and option handlers HANDLERS. */ static void maybe_default_option (struct gcc_options *opts, struct gcc_options *opts_set, const struct default_options *default_opt, - int level, bool size, bool fast, + int level, bool size, bool fast, bool debug, unsigned int lang_mask, const struct cl_option_handlers *handlers, location_t loc, @@ -335,6 +335,8 @@ maybe_default_option (struct gcc_options *opts, gcc_assert (level == 2); if (fast) gcc_assert (level == 3); + if (debug) + gcc_assert (level == 1); switch (default_opt->levels) { @@ -351,7 +353,11 @@ maybe_default_option (struct gcc_options *opts, break; case OPT_LEVELS_1_PLUS_SPEED_ONLY: - enabled = (level >= 1 && !size); + enabled = (level >= 1 && !size && !debug); + break; + + case OPT_LEVELS_1_PLUS_NOT_DEBUG: + enabled = (level >= 1 && !debug); break; case OPT_LEVELS_2_PLUS: @@ -359,7 +365,7 @@ maybe_default_option (struct gcc_options *opts, break; case OPT_LEVELS_2_PLUS_SPEED_ONLY: - enabled = (level >= 2 && !size); + enabled = (level >= 2 && !size && !debug); break; case OPT_LEVELS_3_PLUS: @@ -405,7 +411,7 @@ static void maybe_default_options (struct gcc_options *opts, struct gcc_options *opts_set, const struct default_options *default_opts, - int level, bool size, bool fast, + int level, bool size, bool fast, bool debug, unsigned int lang_mask, const struct cl_option_handlers *handlers, location_t loc, @@ -415,7 +421,8 @@ maybe_default_options (struct gcc_options *opts, for (i = 0; default_opts[i].levels != OPT_LEVELS_NONE; i++) maybe_default_option (opts, opts_set, &default_opts[i], - level, size, fast, lang_mask, handlers, loc, dc); + level, size, fast, debug, + lang_mask, handlers, loc, dc); } /* Table of options enabled by default at different levels. */ @@ -444,7 +451,7 @@ static const struct default_options default_options_table[] = { OPT_LEVELS_1_PLUS, OPT_ftree_dominator_opts, NULL, 1 }, { OPT_LEVELS_1_PLUS, OPT_ftree_dse, NULL, 1 }, { OPT_LEVELS_1_PLUS, OPT_ftree_ter, NULL, 1 }, - { OPT_LEVELS_1_PLUS, OPT_ftree_sra, NULL, 1 }, + { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_ftree_sra, NULL, 1 }, { OPT_LEVELS_1_PLUS, OPT_ftree_copyrename, NULL, 1 }, { OPT_LEVELS_1_PLUS, OPT_ftree_fre, NULL, 1 }, { OPT_LEVELS_1_PLUS, OPT_ftree_copy_prop, NULL, 1 }, @@ -498,7 +505,7 @@ static const struct default_options default_options_table[] = /* Inlining of functions reducing size is a good idea with -Os regardless of them being declared inline. */ { OPT_LEVELS_3_PLUS_AND_SIZE, OPT_finline_functions, NULL, 1 }, - { OPT_LEVELS_1_PLUS, OPT_finline_functions_called_once, NULL, 1 }, + { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_finline_functions_called_once, NULL, 1 }, { OPT_LEVELS_3_PLUS, OPT_funswitch_loops, NULL, 1 }, { OPT_LEVELS_3_PLUS, OPT_fgcse_after_reload, NULL, 1 }, { OPT_LEVELS_3_PLUS, OPT_ftree_vectorize, NULL, 1 }, @@ -540,6 +547,7 @@ default_options_optimization (struct gcc_options *opts, opts->x_optimize = 1; opts->x_optimize_size = 0; opts->x_optimize_fast = 0; + opts->x_optimize_debug = 0; } else { @@ -555,6 +563,7 @@ default_options_optimization (struct gcc_options *opts, opts->x_optimize = 255; opts->x_optimize_size = 0; opts->x_optimize_fast = 0; + opts->x_optimize_debug = 0; } } break; @@ -565,6 +574,7 @@ default_options_optimization (struct gcc_options *opts, /* Optimizing for size forces optimize to be 2. */ opts->x_optimize = 2; opts->x_optimize_fast = 0; + opts->x_optimize_debug = 0; break; case OPT_Ofast: @@ -572,6 +582,15 @@ default_options_optimization (struct gcc_options *opts, opts->x_optimize_size = 0; opts->x_optimize = 3; opts->x_optimize_fast = 1; + opts->x_optimize_debug = 0; + break; + + case OPT_Og: + /* -Og selects optimization level 1. */ + opts->x_optimize_size = 0; + opts->x_optimize = 1; + opts->x_optimize_fast = 0; + opts->x_optimize_debug = 1; break; default: @@ -582,7 +601,8 @@ default_options_optimization (struct gcc_options *opts, maybe_default_options (opts, opts_set, default_options_table, opts->x_optimize, opts->x_optimize_size, - opts->x_optimize_fast, lang_mask, handlers, loc, dc); + opts->x_optimize_fast, opts->x_optimize_debug, + lang_mask, handlers, loc, dc); /* -O2 param settings. */ opt2 = (opts->x_optimize >= 2); @@ -612,7 +632,8 @@ default_options_optimization (struct gcc_options *opts, maybe_default_options (opts, opts_set, targetm_common.option_optimization_table, opts->x_optimize, opts->x_optimize_size, - opts->x_optimize_fast, lang_mask, handlers, loc, dc); + opts->x_optimize_fast, opts->x_optimize_debug, + lang_mask, handlers, loc, dc); } /* After all options at LOC have been read into OPTS and OPTS_SET, @@ -1408,6 +1429,7 @@ common_handle_option (struct gcc_options *opts, case OPT_O: case OPT_Os: case OPT_Ofast: + case OPT_Og: /* Currently handled in a prescan. */ break; |