[PATCH] Move LTO option processing to common code

View: New views
3 Messages — Rating Filter:   Alert me  

[PATCH] Move LTO option processing to common code

by Richard Guenther-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


As requested from Joseph this moves LTO option processing to
common code, -flto and -fwhopr are in common.opt already.

Bootstrapped and tested on x86_64-unknown-linux-gnu, ok?

Thanks,
Richard.

2009-10-31  Richard Guenther  <rguenther@...>

        * c-opts.c (c_common_post_options): Move LTO option processing
        code ...
        * opts.c (decode_options): ... here.

        fortran/
        * options.c (gfc_post_options): Rely on common code processing
        LTO options.  Only enable -fwhole-file here.

Index: trunk/gcc/c-opts.c
===================================================================
*** trunk.orig/gcc/c-opts.c 2009-10-31 13:20:18.000000000 +0100
--- trunk/gcc/c-opts.c 2009-10-31 13:24:45.000000000 +0100
*************** c_common_post_options (const char **pfil
*** 1033,1061 ****
    C_COMMON_OVERRIDE_OPTIONS;
  #endif
 
-   if (flag_lto || flag_whopr)
-     {
- #ifdef ENABLE_LTO
-       flag_generate_lto = 1;
-
-       /* When generating IL, do not operate in whole-program mode.
- Otherwise, symbols will be privatized too early, causing link
- errors later.  */
-       flag_whole_program = 0;
-
-       /* FIXME lto.  Disable var-tracking until debug information
- is properly handled in free_lang_data.  */
-       flag_var_tracking = 0;
- #else
-       error ("LTO support has not been enabled in this configuration");
- #endif
-     }
-
-   /* Reconcile -flto and -fwhopr.  Set additional flags as appropriate and
-      check option consistency.  */
-   if (flag_lto && flag_whopr)
-     error ("-flto and -fwhopr are mutually exclusive");
-
    /* Excess precision other than "fast" requires front-end
       support.  */
    if (c_dialect_cxx ())
--- 1033,1038 ----
Index: trunk/gcc/fortran/options.c
===================================================================
*** trunk.orig/gcc/fortran/options.c 2009-10-31 13:29:42.000000000 +0100
--- trunk/gcc/fortran/options.c 2009-10-31 13:29:45.000000000 +0100
*************** gfc_post_options (const char **pfilename
*** 242,268 ****
    if (flag_whole_program)
      gfc_option.flag_whole_file = 1;
 
    if (flag_lto || flag_whopr)
!     {
! #ifdef ENABLE_LTO
!       flag_generate_lto = 1;
!
!       /* When generating IL, do not operate in whole-program mode.
! Otherwise, symbols will be privatized too early, causing link
! errors later.  */
!       flag_whole_program = 0;
!
!       /* But do enable whole-file mode.  */
!       gfc_option.flag_whole_file = 1;
! #else
!       error ("LTO support has not been enabled in this configuration");
! #endif
!     }
!
!   /* Reconcile -flto and -fwhopr.  Set additional flags as appropriate and
!      check option consistency.  */
!   if (flag_lto && flag_whopr)
!     error ("-flto and -fwhopr are mutually exclusive");
 
    /* -fbounds-check is equivalent to -fcheck=bounds */
    if (flag_bounds_check)
--- 242,250 ----
    if (flag_whole_program)
      gfc_option.flag_whole_file = 1;
 
+   /* Enable whole-file mode if LTO is in effect.  */
    if (flag_lto || flag_whopr)
!     gfc_option.flag_whole_file = 1;
 
    /* -fbounds-check is equivalent to -fcheck=bounds */
    if (flag_bounds_check)
Index: trunk/gcc/opts.c
===================================================================
*** trunk.orig/gcc/opts.c 2009-10-31 13:20:18.000000000 +0100
--- trunk/gcc/opts.c 2009-10-31 13:24:44.000000000 +0100
*************** decode_options (unsigned int argc, const
*** 1117,1122 ****
--- 1117,1144 ----
          PARAM_VALUE (PARAM_STACK_FRAME_GROWTH) = 40;
      }
 
+   if (flag_lto || flag_whopr)
+     {
+ #ifdef ENABLE_LTO
+       flag_generate_lto = 1;
+
+       /* When generating IL, do not operate in whole-program mode.
+ Otherwise, symbols will be privatized too early, causing link
+ errors later.  */
+       flag_whole_program = 0;
+
+       /* FIXME lto.  Disable var-tracking until debug information
+ is properly handled in free_lang_data.  */
+       flag_var_tracking = 0;
+ #else
+       error ("LTO support has not been enabled in this configuration");
+ #endif
+     }
+
+   /* Reconcile -flto and -fwhopr.  Set additional flags as appropriate and
+      check option consistency.  */
+   if (flag_lto && flag_whopr)
+     error ("-flto and -fwhopr are mutually exclusive");
  }
 
  #define LEFT_COLUMN 27

Re: [PATCH] Move LTO option processing to common code

by Steve Kargl :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sat, Oct 31, 2009 at 03:18:26PM +0100, Richard Guenther wrote:

>
> As requested from Joseph this moves LTO option processing to
> common code, -flto and -fwhopr are in common.opt already.
>
> Bootstrapped and tested on x86_64-unknown-linux-gnu, ok?
>
> Thanks,
> Richard.
>
> 2009-10-31  Richard Guenther  <rguenther@...>
>
> * c-opts.c (c_common_post_options): Move LTO option processing
> code ...
> * opts.c (decode_options): ... here.
>
> fortran/
> * options.c (gfc_post_options): Rely on common code processing
> LTO options.  Only enable -fwhole-file here.
>

The Fortran part is OK.

--
Steve

Re: [PATCH] Move LTO option processing to common code

by Diego Novillo-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sat, Oct 31, 2009 at 09:18, Richard Guenther <rguenther@...> wrote:

> 2009-10-31  Richard Guenther  <rguenther@...>
>
>        * c-opts.c (c_common_post_options): Move LTO option processing
>        code ...
>        * opts.c (decode_options): ... here.

OK.


Diego.