re PR lto/41565 (-m32 causes an ICE when the object files were compiled with 64bit)
authorRichard Guenther <rguenther@suse.de>
Tue, 13 Oct 2009 12:42:30 +0000 (12:42 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 13 Oct 2009 12:42:30 +0000 (12:42 +0000)
2009-10-13  Richard Guenther  <rguenther@suse.de>

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.

From-SVN: r152705

gcc/ChangeLog
gcc/lto-opts.c
gcc/opts.c
gcc/opts.h

index c60bd482e71f8bb780cbae4778f73bbf4ce2072d..d63029eec054b3a7c8208f74330de1f604a83567 100644 (file)
@@ -1,3 +1,15 @@
+2009-10-13  Richard Guenther  <rguenther@suse.de>
+
+       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  <mjambor@suse.cz>
 
        PR tree-optimization/41661
index 2a379f40fdcf793f061ddaabb1e9049d55aeb7de..fd485b9db60e79053ce0bcc97b71370e90eb7f69 100644 (file)
@@ -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 ();
     }
index b12ed14c21d471c1c2c52f464c131fc7c093e343..51a0cb954196be8224d6dbe6f3d86beb0740adf6 100644 (file)
@@ -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.  */
 
index b4be11116750490f52ec6fda51112f9d06404d5e..a2eef1938c75973f59f7bb4880d4bf79683a37f2 100644 (file)
@@ -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);