This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[LTO][PATCH] Add lang-hooks for LTO operation modes.


Hi,

      This patch adds two lang-hooks for various LTO modes.  There are 5 modes

LTO_MODE_NOT_LTO       // not doing LTO
LTO_MODE_LGEN             // FE other than lto1 emitting LTO IR
LTO_MODE_NORMAL        // lto1 converts LGEN objects to assembly
LTO_MODE_WPA                // lto1 performs whole-program-analysis,
convers LGEN objects to WPA objects
LTO_MODE_LTRAN            // lto1 converts WPA objects to assembly.

The modes are controlled by a signle -flto-mode= switch.  When given
to the gcc driver and collect2, the driver and collect2 figure out the
appropriate modes passed to the front-ends.  The patch has been tested
and boot-strapped on i686-unknown-linux-gnu.

The gcc driver still recognizes -flto and -flto-single for backward
compatibility but these are handled by substituting with -flto-mode as
appropriate.

-Doug

ChangeLog:
2008-09-17  Doug Kwan  <dougkwan@google.com>

        * gcc.c (lto_single):  Remove.
        (lto_mode): New variable.
        (LINK_COMMAND_SPEC): Replace flto flag with call to linker-lto-mode.
        (cc1_options): Group all non-LTO spec bits into ..
        (cc1_non_lto_options): New spec.
        (invoke_lto_single): Use -flto-mode flag as appropriate. Reformat to
        fit in 80 columns.
        (static_specs): Add cc1_non_lto_options.
        (spec_function): Add lto-mode, linker-lto-mode and lto1-options.
        (set_lto_mode): New function.
        (process_command): Handle -flto and -flto-single and as special
        aliases of -flto-mode.
        (lto_single_spec_function): Replace lto_single with lto_mode.
        (lto_mode_spec_function): New.
        (lto_linker_options_spec_function): Ditto.
        (lto1_options_spec_function): Ditto.
        * lto-function-out.c (langhooks.h): Include.
        (lto_output): Use get_mode hook instead of flag_wpa to check if LTO
        is running in WPA mode.
        * toplev.c (compile_file): Use lang-hook to check if output
        a file.
        * lto-cgraph.c (output_edge): Use lang-hook instead of
        flag_wpa.
        * ipa-inline.c (cgraph_default_inline_p): Ditto.
        * opts.c (decode_options): Ditto.
        (common_handle_option): Validate -flto-mode argument.
        * langhooks.c (lhd_get_mode): New lang-hook default.
        (lhd_set_mode): Ditto.
        * langhooks.h (LTO_MODE_NOT_LTO, LTO_MODE_LGEN, LTO_MODE_NORMAL,
        LTO_MODE_WAP, LTO_MODE_LTRAN): New macros.
        (lto_mode_generate_lto_p): New inline.
        (lang_hooks_for_lto): Add new hooks GET_MODE and SET_MODE.
        * common.opt (flto): Remove.
        (flto-mode): New option.
        (fwpa): Remove.
        * Makefile.in (lto-function-out.o): Add langhooks.h to dependencies.
        * passes.c (ipa_write_summaries): Use lang-hook instead of
        flag_generate_lto.
        (ipa_write_summaries_of_cgraph_node_set): Ditto.
        * c-lang.c (lto_mode): New var.
        (c_get_lto_mode): New lang-hook. Use it.
        (c_set_lto_mode): New lang-hook. Use it.
        * lto-section-out.c (produce_asm_for_decls): Use lang-hook instead of
        flag_generate_lto.
        * collect2.c (lto_flag): Remove.
        (lto_mode): New var.
        (maybe_run_lto_and_relink): Pass -flto-mode to sub-processes.
        Handle -flto-mode instead of -flto.
        (main): Handle -flto-mode instead of -flto.  Replace lto_flag with
        lto_mode.
        * langhooks-def.h (lhd_get_mode, lhd_set_mode): New prototypes.
        (LANG_HOOKS_GET_MODE, LANG_HOOKS_SET_MODE): New macros.
        (LANG_HOOKS_LTO): Include the above macros.

cp/ChangeLog:
2008-09-17  Doug Kwan  <dougkwan@google.com>

        * cp-lang.c (cp_get_lto_mode): New hook.  Use it.
        (cp_set_lto_mode): Ditto.

lto/ChangeLog:
2008-09-17  Doug Kwan  <dougkwan@google.com>

        lto.c (lto_materialize_function): Use lang-hook instead of
        flag_wpa.
        (lto_main): Use lang-hook instead of flag_wpa.  Remove unused
        wrapper code.
        * lang-specs.h (@lto): Use cc1_non_lto_options and lto1-options
        instead of cc1_lto_options.
        * lto.h (lto_get_mode, lto_set_mode): New prototypes.
        * lto-lang.c (lto_init): Remove code to reset flag_generate_lto.
        (lto_current_mode): New var.
        (lto_get_mode): New lang-hook. Use it.
        (lto_set_mode): Ditto.

Attachment: patch.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]