diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c60bd482e71..d63029eec05 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2009-10-13 Richard Guenther + + PR lto/41565 + * opts.c (handle_option): Split out code to handle setting + the options flag var ... + (set_option): ... here. + * opts.h (set_option): Declare. + * lto-opts.c (register_user_option_p): Include -fexceptions + and all position independent code variants. + (handle_common_option): Remove. + (lto_reissue_options): Use set_option. + 2009-10-13 Martin Jambor PR tree-optimization/41661 diff --git a/gcc/lto-opts.c b/gcc/lto-opts.c index 2a379f40fdc..fd485b9db60 100644 --- a/gcc/lto-opts.c +++ b/gcc/lto-opts.c @@ -208,10 +208,19 @@ input_string_block (struct lto_input_block *ib) static bool register_user_option_p (size_t code, int type) { - return type == CL_TARGET - || (type == CL_COMMON - && (code == OPT_fPIC - || code == OPT_fcommon)); + if (type == CL_TARGET) + return true; + else if (type == CL_COMMON) + { + return (code == OPT_fPIC + || code == OPT_fpic + || code == OPT_fPIE + || code == OPT_fpie + || code == OPT_fcommon + || code == OPT_fexceptions); + } + + return false; } /* Note command line option with the given TYPE and CODE, ARG, and VALUE. @@ -358,32 +367,6 @@ lto_read_file_options (struct lto_file_decl_data *file_data) lto_free_section_data (file_data, LTO_section_opts, 0, data, len); } -/* Re-handle option with type TYPE and CODE, ARG, and VALUE. Logic extracted - from common_handle_option() in opts.c. - - FIXME lto. This section is not complete. If extended to handle - optimization options, note that changing these after opts.c prescan may - involve also adjusting other options that were defaulted from initial - optimization option values. */ - -static void -handle_common_option (size_t code, const char *arg ATTRIBUTE_UNUSED, int value) -{ - switch (code) - { - case OPT_fPIC: - flag_pic = !!value; - break; - - case OPT_fcommon: - flag_no_common = !value; - break; - - default: - gcc_unreachable (); - } -} - /* Concatenate the user options and any file options read from an LTO IL file, and reissue them as if all had just been read in from the command line. As with serialization, file options precede user options. */ @@ -397,10 +380,15 @@ lto_reissue_options (void) for (i = 0; VEC_iterate (opt_t, opts, i, o); i++) { + const struct cl_option *option = &cl_options[o->code]; + + if (option->flag_var) + set_option (option, o->value, o->arg); + if (o->type == CL_TARGET) targetm.handle_option (o->code, o->arg, o->value); else if (o->type == CL_COMMON) - handle_common_option (o->code, o->arg, o->value); + gcc_assert (option->flag_var); else gcc_unreachable (); } diff --git a/gcc/opts.c b/gcc/opts.c index b12ed14c21d..51a0cb95419 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -610,32 +610,7 @@ handle_option (const char **argv, unsigned int lang_mask) } if (option->flag_var) - switch (option->var_type) - { - case CLVC_BOOLEAN: - *(int *) option->flag_var = value; - break; - - case CLVC_EQUAL: - *(int *) option->flag_var = (value - ? option->var_value - : !option->var_value); - break; - - case CLVC_BIT_CLEAR: - case CLVC_BIT_SET: - if ((value != 0) == (option->var_type == CLVC_BIT_SET)) - *(int *) option->flag_var |= option->var_value; - else - *(int *) option->flag_var &= ~option->var_value; - if (option->flag_var == &target_flags) - target_flags_explicit |= option->var_value; - break; - - case CLVC_STRING: - *(const char **) option->flag_var = arg; - break; - } + set_option (option, value, arg); if (option->flags & lang_mask) { @@ -2349,6 +2324,42 @@ get_option_state (int option, struct cl_option_state *state) return true; } +/* Set *OPTION according to VALUE and ARG. */ + +void +set_option (const struct cl_option *option, int value, const char *arg) +{ + if (!option->flag_var) + return; + + switch (option->var_type) + { + case CLVC_BOOLEAN: + *(int *) option->flag_var = value; + break; + + case CLVC_EQUAL: + *(int *) option->flag_var = (value + ? option->var_value + : !option->var_value); + break; + + case CLVC_BIT_CLEAR: + case CLVC_BIT_SET: + if ((value != 0) == (option->var_type == CLVC_BIT_SET)) + *(int *) option->flag_var |= option->var_value; + else + *(int *) option->flag_var &= ~option->var_value; + if (option->flag_var == &target_flags) + target_flags_explicit |= option->var_value; + break; + + case CLVC_STRING: + *(const char **) option->flag_var = arg; + break; + } +} + /* Enable a warning option as an error. This is used by -Werror= and also by legacy Werror-implicit-function-declaration. */ diff --git a/gcc/opts.h b/gcc/opts.h index b4be1111675..a2eef1938c7 100644 --- a/gcc/opts.h +++ b/gcc/opts.h @@ -103,6 +103,7 @@ extern void prune_options (int *argcp, char ***argvp); extern void decode_options (unsigned int argc, const char **argv); extern int option_enabled (int opt_idx); extern bool get_option_state (int, struct cl_option_state *); +extern void set_option (const struct cl_option *, int, const char *); extern void enable_warning_as_error (const char *arg, int value, unsigned int lang_mask);