OSDN Git Service

PR target/45670
[pf3gnuchains/gcc-fork.git] / gcc / lto-opts.c
index 8405714..66010c6 100644 (file)
@@ -1,6 +1,6 @@
 /* LTO IL options.
 
-   Copyright 2009 Free Software Foundation, Inc.
+   Copyright 2009, 2010 Free Software Foundation, Inc.
    Contributed by Simon Baldwin <simonb@google.com>
 
 This file is part of GCC.
@@ -31,7 +31,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "opts.h"
 #include "options.h"
 #include "target.h"
-#include "diagnostic-core.h"
+#include "diagnostic.h"
 #include "toplev.h"
 #include "lto-streamer.h"
 
@@ -128,7 +128,7 @@ clear_options (VEC(opt_t, heap) **opts_p)
   int i;
   opt_t *o;
 
-  for (i = 0; VEC_iterate (opt_t, *opts_p, i, o); i++)
+  FOR_EACH_VEC_ELT (opt_t, *opts_p, i, o)
     free (o->arg);
 
   VEC_free (opt_t, heap, *opts_p);
@@ -278,7 +278,7 @@ output_options (struct lto_output_stream *stream)
 
   output_data_stream (stream, &length, sizeof (length));
 
-  for (i = 0; VEC_iterate (opt_t, opts, i, o); i++)
+  FOR_EACH_VEC_ELT (opt_t, opts, i, o)
     {
       output_data_stream (stream, &o->type, sizeof (o->type));
       output_data_stream (stream, &o->code, sizeof (o->code));
@@ -294,7 +294,7 @@ output_options (struct lto_output_stream *stream)
 void
 lto_write_options (void)
 {
-  char *const section_name = lto_get_section_name (LTO_section_opts, NULL);
+  char *const section_name = lto_get_section_name (LTO_section_opts, NULL, NULL);
   struct lto_output_stream stream;
   struct lto_simple_header header;
   struct lto_output_stream *header_stream;
@@ -349,21 +349,39 @@ input_options (struct lto_input_block *ib)
 void
 lto_read_file_options (struct lto_file_decl_data *file_data)
 {
-  size_t len;
-  const char *data;
+  size_t len, l, skip;
+  const char *data, *p;
   const struct lto_simple_header *header;
   int32_t opts_offset;
   struct lto_input_block ib;
 
   data = lto_get_section_data (file_data, LTO_section_opts, NULL, &len);
-  header = (const struct lto_simple_header *) data;
-  opts_offset = sizeof (*header);
-
-  lto_check_version (header->lto_header.major_version,
-                    header->lto_header.minor_version);
-
-  LTO_INIT_INPUT_BLOCK (ib, data + opts_offset, 0, header->main_size);
-  input_options (&ib);
+  if (!data)
+         return;
+
+  /* Option could be multiple sections merged (through ld -r) 
+     Keep reading all options.  This is ok right now because
+     the options just get mashed together anyways.
+     This will have to be done differently once lto-opts knows
+     how to associate options with different files. */
+  l = len;
+  p = data;
+  do 
+    { 
+      header = (const struct lto_simple_header *) p;
+      opts_offset = sizeof (*header);
+
+      lto_check_version (header->lto_header.major_version,
+                        header->lto_header.minor_version);
+      
+      LTO_INIT_INPUT_BLOCK (ib, p + opts_offset, 0, header->main_size);
+      input_options (&ib);
+      
+      skip = header->main_size + opts_offset;
+      l -= skip;
+      p += skip;
+    } 
+  while (l > 0);
 
   lto_free_section_data (file_data, LTO_section_opts, 0, data, len);
 }
@@ -379,17 +397,19 @@ lto_reissue_options (void)
   int i;
   opt_t *o;
 
-  for (i = 0; VEC_iterate (opt_t, opts, i, o); i++)
+  FOR_EACH_VEC_ELT (opt_t, opts, i, o)
     {
-      const struct cl_option *option = &cl_options[o->code];
+      void *flag_var = option_flag_var (o->code, &global_options);
 
-      if (option->flag_var)
-       set_option (o->code, o->value, o->arg, 0 /*DK_UNSPECIFIED*/);
+      if (flag_var)
+       set_option (&global_options, &global_options_set,
+                   o->code, o->value, o->arg,
+                   DK_UNSPECIFIED, global_dc);
 
       if (o->type == CL_TARGET)
        targetm.handle_option (o->code, o->arg, o->value);
       else if (o->type == CL_COMMON)
-       gcc_assert (option->flag_var);
+       gcc_assert (flag_var);
       else
        gcc_unreachable ();
     }