One of the optimizations performed during an IPO compilation is code layout. IPO analysis determines a layout order for all of the routines for which it has IR. If a single object is being generated, the compiler generates the layout simply by compiling the routines in the desired order.
For a multi-object IPO compilation, the compiler must tell the linker about the desired order. The compiler first puts each routine in a named text section that varies depending on the platform:
Linux* Behavior Summary |
---|
The first routine is placed in .text00001, the second is placed in .text00002, and so on. It then generates a linker script that tells the linker to first link contributions from .text00001, then .text00002. This happens transparently when the same ifort xild (Linux*) or xilink (Windows*) invocation is used for both the link-time compilation and the final link. |
Windows* Behavior Summary |
The first routine is placed in .text$00001, the second is placed in .text$00002, and so on. The Windows linker (link) automatically collates these sections in the desired order. |
However, the linker script must be taken into account if you use either -ipo-c or -ipo-S (Linux*) or /Qipo-c or /Qipo-S (Windows*).
With these switches, the IPO compilation and actual link are done by different invocations of the compiler. When this occurs, the compiler issues an informational message indicating that it is generating an explicit linker script, ipo_layout.script.
When ipo_layout.script is generated, the typical response is to modify your link command to use this script:
Example |
---|
--script=ipo_layout.script |
If your application already requires a custom linker script, you can place the necessary contents of ipo_layout.script in your script.
The layout-specific content of ipo_layout.script is at the beginning of the description of the .text section. For example, to describe the layout order for 12 routines:
Example output |
---|
.text : |
For applications that already require a linker script, you can add this section of the .text section description to the customized linker script. If you add these lines to your linker script, it is desirable to add additional entries to account for future development. This is harmless, since the “*(…)” syntax makes these contributions optional.
If you choose to not use the linker script your application will still build, but the layout order will be random. This may have an adverse affect on application performance, particularly for large applications.