}
/* 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,
gcc_assert (level == 2);
if (fast)
gcc_assert (level == 3);
+ if (debug)
+ gcc_assert (level == 1);
switch (default_opt->levels)
{
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:
break;
case OPT_LEVELS_2_PLUS_SPEED_ONLY:
- enabled = (level >= 2 && !size);
+ enabled = (level >= 2 && !size && !debug);
break;
case OPT_LEVELS_3_PLUS:
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,
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. */
{ 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 },
/* 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 },
opts->x_optimize = 1;
opts->x_optimize_size = 0;
opts->x_optimize_fast = 0;
+ opts->x_optimize_debug = 0;
}
else
{
opts->x_optimize = 255;
opts->x_optimize_size = 0;
opts->x_optimize_fast = 0;
+ opts->x_optimize_debug = 0;
}
}
break;
/* 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:
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:
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);
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,
case OPT_O:
case OPT_Os:
case OPT_Ofast:
+ case OPT_Og:
/* Currently handled in a prescan. */
break;
static bool
gate_all_optimizations (void)
{
- return (optimize >= 1
- /* Don't bother doing anything if the program has errors.
- We have to pass down the queue if we already went into SSA */
- && (!seen_error () || gimple_in_ssa_p (cfun)));
+ return optimize >= 1 && !optimize_debug;
}
static struct gimple_opt_pass pass_all_optimizations =
}
};
+/* Gate: execute, or not, all of the non-trivial optimizations. */
+
+static bool
+gate_all_optimizations_g (void)
+{
+ return optimize >= 1 && optimize_debug;
+}
+
+static struct gimple_opt_pass pass_all_optimizations_g =
+{
+ {
+ GIMPLE_PASS,
+ "*all_optimizations_g", /* name */
+ gate_all_optimizations_g, /* gate */
+ NULL, /* execute */
+ NULL, /* sub */
+ NULL, /* next */
+ 0, /* static_pass_number */
+ TV_OPTIMIZE, /* tv_id */
+ 0, /* properties_required */
+ 0, /* properties_provided */
+ 0, /* properties_destroyed */
+ 0, /* todo_flags_start */
+ 0 /* todo_flags_finish */
+ }
+};
+
static bool
gate_rest_of_compilation (void)
{
NEXT_PASS (pass_uncprop);
NEXT_PASS (pass_local_pure_const);
}
+ NEXT_PASS (pass_all_optimizations_g);
+ {
+ struct opt_pass **p = &pass_all_optimizations_g.pass.sub;
+ NEXT_PASS (pass_remove_cgraph_callee_edges);
+ NEXT_PASS (pass_strip_predict_hints);
+ /* Lower remaining pieces of GIMPLE. */
+ NEXT_PASS (pass_lower_complex);
+ NEXT_PASS (pass_lower_vector_ssa);
+ /* Perform simple scalar cleanup which is constant/copy propagation. */
+ NEXT_PASS (pass_ccp);
+ NEXT_PASS (pass_copy_prop);
+ NEXT_PASS (pass_rename_ssa_copies);
+ NEXT_PASS (pass_dce);
+ /* Fold remaining builtins. */
+ NEXT_PASS (pass_object_sizes);
+ NEXT_PASS (pass_fold_builtins);
+ /* ??? We do want some kind of loop invariant motion, but we possibly
+ need to adjust LIM to be more friendly towards preserving accurate
+ debug information here. */
+ NEXT_PASS (pass_late_warn_uninitialized);
+ NEXT_PASS (pass_uncprop);
+ NEXT_PASS (pass_local_pure_const);
+ }
NEXT_PASS (pass_tm_init);
{
struct opt_pass **p = &pass_tm_init.pass.sub;