Developer Guide and Reference

ID 767251
Date 10/31/2024
Public
Document Table of Contents

Use Interprocedural Optimization

This topic discusses how to use IPO from the command line.

Compile and Link Using IPO

To enable IPO, you first compile each source file, then link the resulting source files.

Linux

  1. Compile your source files with the flto compiler option:

    ifx -flto -c a.f90 b.f90 c.f90

    The command produces a.o, b.o, and c.o object files.

    Use the c compiler option to stop compilation after generating object files. The output files contain compiler intermediate representation (IR) corresponding to the compiled source files.

  2. Link the resulting files. The following example command will produce an executable named app:

    ifx -flto -o app a.o b.o c.o

    The command invokes the compiler on the objects containing IR and creates a new list of objects to be linked.

The separate compile and link commands from the previous steps can be combined into a single command, for example:

ifx -flto -o app a.f90 b.f90 c.f90

The ifx command, shown in the examples, calls GCC ld to link the specified object files and produce the executable application, which is specified by the -o option.

While the default linker for Linux is the standard Berkeley Free Distribution, you can also use the LLVM project linker, LLD, by specifying -fuse=lld on the command line.

Windows

  1. Compile your source files with the /Qipo compiler option:

     ifx /Qipo /c a.f90 b.f90 c.f90

    The command produces a.obj, b.obj, and c.obj object files.

    Use the c compiler option to stop compilation after generating .obj files. The output files contain compiler intermediate representation (IR) corresponding to the compiled source files.

  2. Link the resulting files. The following example command will produce an executable named app:

    ifx /Qipo /exe:app a.obj b.obj c.obj

    The command invokes the compiler on the objects containing IR and creates a new list of objects to be linked.

The separate compile and link commands from the previous steps can be combined into a single command, for example:

ifx /Qipo /exe:app a.f90 b.f90 c.f90

The ifx command, shown in the examples, calls link.exe to link the specified object files and produce the executable application, which is specified by the /exe option.

For Windows, the only possible linker is LLD, which is specified by default if you use /Qipo.

See Also