The following makes sure the languages default of -ffp-contract
is properly transfered to the LTO stage (which defaults to "fast").
Merging different options from different TUs is done conservatively.

LTO bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2013-11-20  Richard Biener  <rguent...@suse.de>

        PR lto/59035
        * lto-opts.c (lto_write_options): Write defaults only if
        they were not explicitely specified.  Also write
        -ffp-contract default.
        * lto-wrapper.c (merge_and_complain): Merge -ffp-contract
        conservatively.
        (run_gcc): Pass through -ffp-contract.

Index: gcc/lto-opts.c
===================================================================
*** gcc/lto-opts.c      (revision 205009)
--- gcc/lto-opts.c      (working copy)
*************** lto_write_options (void)
*** 85,98 ****
       function rather than per compilation unit.  */
    /* -fexceptions causes the EH machinery to be initialized, enabling
       generation of unwind data so that explicit throw() calls work.  */
!   if (global_options.x_flag_exceptions)
      append_to_collect_gcc_options (&temporary_obstack, &first_p,
                                   "-fexceptions");
    /* -fnon-call-exceptions changes the generation of exception
        regions.  It is enabled implicitly by the Go frontend.  */
!   if (global_options.x_flag_non_call_exceptions)
      append_to_collect_gcc_options (&temporary_obstack, &first_p,
                                   "-fnon-call-exceptions");
  
    /* Output explicitly passed options.  */
    for (i = 1; i < save_decoded_options_count; ++i)
--- 85,119 ----
       function rather than per compilation unit.  */
    /* -fexceptions causes the EH machinery to be initialized, enabling
       generation of unwind data so that explicit throw() calls work.  */
!   if (!global_options_set.x_flag_exceptions
!       && global_options.x_flag_exceptions)
      append_to_collect_gcc_options (&temporary_obstack, &first_p,
                                   "-fexceptions");
    /* -fnon-call-exceptions changes the generation of exception
        regions.  It is enabled implicitly by the Go frontend.  */
!   if (!global_options_set.x_flag_non_call_exceptions
!       && global_options.x_flag_non_call_exceptions)
      append_to_collect_gcc_options (&temporary_obstack, &first_p,
                                   "-fnon-call-exceptions");
+   /* The default -ffp-contract changes depending on the language
+      standard.  Pass thru conservative standard settings.  */
+   if (!global_options_set.x_flag_fp_contract_mode)
+     switch (global_options.x_flag_fp_contract_mode)
+       {
+       case FP_CONTRACT_OFF:
+       append_to_collect_gcc_options (&temporary_obstack, &first_p,
+                                      "-ffp-contract=off");
+       break;
+       case FP_CONTRACT_ON:
+       append_to_collect_gcc_options (&temporary_obstack, &first_p,
+                                      "-ffp-contract=on");
+       break;
+       case FP_CONTRACT_FAST:
+       /* Nothing.  That merges conservatively and is the default for LTO.  */
+       break;
+       default:
+       gcc_unreachable ();
+       }
  
    /* Output explicitly passed options.  */
    for (i = 1; i < save_decoded_options_count; ++i)
Index: gcc/lto-wrapper.c
===================================================================
*** gcc/lto-wrapper.c   (revision 205009)
--- gcc/lto-wrapper.c   (working copy)
*************** merge_and_complain (struct cl_decoded_op
*** 422,427 ****
--- 422,439 ----
            append_option (decoded_options, decoded_options_count, foption);
          break;
  
+       case OPT_ffp_contract_:
+         /* For selected options we can merge conservatively.  */
+         for (j = 0; j < *decoded_options_count; ++j)
+           if ((*decoded_options)[j].opt_index == foption->opt_index)
+             break;
+         if (j == *decoded_options_count)
+           append_option (decoded_options, decoded_options_count, foption);
+         /* FP_CONTRACT_OFF < FP_CONTRACT_ON < FP_CONTRACT_FAST.  */
+         else if (foption->value < (*decoded_options)[j].value)
+           (*decoded_options)[j] = *foption;
+         break;
+ 
        case OPT_freg_struct_return:
        case OPT_fpcc_struct_return:
          for (j = 0; j < *decoded_options_count; ++j)
*************** run_gcc (unsigned argc, char *argv[])
*** 578,583 ****
--- 590,596 ----
        case OPT_fgnu_tm:
        case OPT_freg_struct_return:
        case OPT_fpcc_struct_return:
+       case OPT_ffp_contract_:
          break;
  
        default:

Reply via email to