Intel® oneAPI DPC++/C++ Compiler Developer Guide and Reference

ID 767253
Date 9/08/2022
Public

A newer version of this document is available. Customers should click here to go to the newest version.

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 ipo compiler option:

    icpx -ipo -c a.cpp b.cpp c.cpp

    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:

    icpx -ipo -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. Alternately, you can use the tool, with the appropriate linking options.

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

icpx -ipo -o app a.cpp b.cpp c.cpp

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

Windows

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

    icx /Qipo /c a.cpp b.cpp c.cpp

    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:

    icx /Qipo /Feapp 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. Alternately, you can use the xilink tool, with the appropriate linking options.

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

icx /Qipo /Feapp a.cpp b.cpp c.cpp

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

NOTE:

Linux: Using icpx allows the compiler to use standard C++ libraries automatically; icx will not use the standard C++ libraries automatically.

The Intel linking tools emulate the behavior of compiling at -O0 (Linux) and /Od (Windows) option.

If multiple file IPO is applied to a series of object files, no one which are mock object files, no multi-file IPO is performed. The object files are simply linked with the linker.

See Also