Ok for google branches It is better to have a higher level compiler option to be introduced for this purpose instead of asking user to specify the plugin path. The option should enable 1) ffunction-sections; 2) cgraph note section genration; 3) enable the plugin. One possibility is to enhance the -freorder-functions option for this:
-freorder-functions=hotness:affinity:.... the suboptions can be used to specify layout algorithm used. Can be done as follow ups. David On 2011/08/03 03:36:52, Sriraman wrote:
Hi,
This patch adds a new linker plugin to re-order functions. The plugin constructs an annotated callgraph with edge profile information and then repeatedly groups sections that are connected by hot edges and passes the new function layout to the linker. The grouping is done similar to the Pettis Hansen code ordering scheme.
How to use the plugin:
During Profile use build stage of Feedback-directed builds, use the
flags:
-fcallgraph-profiles-sections
-Wl,--plugin,<gcc_install_dir>/libexec/gcc/x86_64-unknown-linux-gnu/4.6.x-google/libfunction_reordering_plugin.so
The first flag generates special .note.callgraph.text sections which contain the callgraph profiles that are read by the plugin and an new function layout is generated. The ordering of sections is dumped in file final_layout.txt.
The plugin itself is implemented in the three files: function_ordering_plugin.cc, callgraph.cc, and callgraph.h. The file include/plugin-api.h has changes which has already been submitted to trunk. The rest is related to Makefiles and configure scripts to build and install the plugin.
Please find the patch here: http://codereview.appspot.com/4802070/
Thanks, -Sriraman.
http://codereview.appspot.com/4802070/