@cindex wpa
@cindex ltrans
+Link Time Optimization (LTO) gives GCC the capability of
+dumping its internal representation (GIMPLE) to disk,
+so that all the different compilation units that make up
+a single executable can be optimized as a single module.
+This expands the scope of inter-procedural optimizations
+to encompass the whole program (or, rather, everything
+that is visible at link time).
+
+@menu
+* LTO Overview:: Overview of LTO.
+* LTO object file layout:: LTO file sections in ELF.
+* IPA:: Using summary information in IPA passes.
+* WHOPR:: Whole program assumptions,
+ linker plugin and symbol visibilities.
+* Internal flags:: Internal flags controlling @code{lto1}.
+@end menu
+
+@node LTO Overview
@section Design Overview
Link time optimization is implemented as a GCC front end for a
whole program into memory.
+@node LTO object file layout
@section LTO file sections
LTO information is stored in several ELF sections inside object files.
@end itemize
+@node IPA
@section Using summary information in IPA passes
Programs are represented internally as a @emph{callgraph} (a
devirtualization pass. The inliner also uses jump functions to
perform inlining of callbacks.
+@node WHOPR
@section Whole program assumptions, linker plugin and symbol visibilities
Link-time optimization gives relatively minor benefits when used
plugin GCC also assumes that symbols are declared @code{hidden}
and not referred by non-LTO code by default.
+@node Internal flags
@section Internal flags controlling @code{lto1}
The following flags are passed into @command{lto1} and are not
@chapter Plugins
@cindex Plugins
+GCC plugin is a loadable module that provides extra
+features to the compiler, which they can further pass
+around as a shareable module.
+
+GCC plugins provide developers with a rich subset of
+the GCC API to allow them to extend GCC as they see fit.
+Whether it is writing an additional optimization pass,
+transforming code, or analyzing information, plugins
+can be quite useful.
+
+@menu
+* Plugins loading:: How can we load plugins.
+* Plugin API:: The APIs for plugins.
+* Plugins pass:: How a plugin interact with the pass manager.
+* Plugins GC:: How a plugin Interact with GCC Garbage Collector.
+* Plugins description:: Giving information about a plugin itself.
+* Plugins attr:: Registering custom attributes or pragmas.
+* Plugins recording:: Recording information about pass execution.
+* Plugins gate:: Controlling which passes are being run.
+* Plugins tracking:: Keeping track of available passes.
+* Plugins building:: How can we build a plugin.
+@end menu
+
+@node Plugins loading
@section Loading Plugins
Plugins are supported on platforms that support @option{-ldl
the same as @option{-fplugin=`gcc -print-file-name=plugin`/@var{name}.so},
using backquote shell syntax to query the @file{plugin} directory.
+@node Plugin API
@section Plugin API
Plugins are activated by the compiler at specific events as defined in
using functions like @code{c_register_pragma} or
@code{c_register_pragma_with_expansion}.
+@node Plugins pass
@section Interacting with the pass manager
There needs to be a way to add/reorder/remove passes dynamically. This
@end smallexample
+@node Plugins GC
@section Interacting with the GCC Garbage Collector
Some plugins may want to be informed when GGC (the GCC Garbage
or @code{PLUGIN_REGISTER_GGC_CACHES}.
+@node Plugins description
@section Giving information about a plugin
A plugin should give some information to the user about itself. This
init routine using @code{register_callback} with the
@code{PLUGIN_INFO} pseudo-event and a null callback.
+@node Plugins attr
@section Registering custom attributes or pragmas
For analysis (or other) purposes it is useful to be able to add custom
your plugin) as the ``space'' argument of your pragma.
+@node Plugins recording
@section Recording information about pass execution
The event PLUGIN_PASS_EXECUTION passes the pointer to the executed pass
in your plugin(s) in order to get context for the pass execution.
+@node Plugins gate
@section Controlling which passes are being run
After the original gate function for a pass is called, its result
You can both read and write the gate status via the passed pointer.
+@node Plugins tracking
@section Keeping track of available passes
When your plugin is loaded, you can inspect the various
@code{gcc_data} pointing to the new pass.
+@node Plugins building
@section Building GCC plugins
If plugins are enabled, GCC installs the headers needed to build a