-ipa

Controls Interprocedural Analysis (IPA) that lets the compiler generate better optimizations by evaluating all the functions and data objects in a file or program before generating code.

Syntax
  -ipa file | function | off | program | program-final

  

function | off

Per-function optimization. This is the default option.

file

Per file optimization.

program

Per-program optimization

Remarks

See Interprocedural Analysis.

Note: -ipa program mode is available only with command line compiler.

Using IPA mode from command-line tools is more complicated. If you specify all source files on the command-line you can just use -ipa program:

Use the off or function arguments to turn interprocedural analysis off. This is the default setting.

Use the file argument to apply interprocedural analysis at the file level. For example, if the name of the compiler is mwcc, the command: mwcc -ipa file -c file1.c file2.c generates object code and applies this optimization to file file1.c and then file2.c, but does not apply the optimization across both files. For each source file, this command generates a regular object code file (a file with a name that ends with ".o" or ".obj"), which is empty. It also generates an additional file ending with ".irobj". This additional object code file contains the object code to which the compiler has applied interprocedural analysis.

This example compiles the same source files again, applies file-level analysis, then links object code into an output file named myprog:

  mwcc -o myprog -ipa file -c file1.c file2.c

Use the program argument to apply this optimization among all files being compiled and linked. For example: mwcc -o myprog -ipa program file1.c file2.c

generates object code, applies this optimization among all resulting object code files to link it into an output file named myprog.

To separate compiling and linking steps for program-level interprocedural analysis, use the program and program-final arguments. For example:

  mwcc -ipa program -c file1.c 
  mwcc -ipa program -c file2.c

compiles file1.c and file2.c into empty regular object files named file1.o and file2.o, respectively, and optimized object files named file1.irobj and file2.irobj.

To link object files, refer to the regular object files or the optimized object files. For example:

  mwcc -o myprog -ipa program file1.o file2.o 

or, equivalently:

  mwcc -o myprog -ipa program file1.irobj file2.irobj

To invoke the linker directly, use the program-final argument. For example, these commands prepare object code for linking, then invoke the linker directly (named mwld in this example):

  mwcc -ipa program-final file1.irobj file2.irobj 
  mwld -o myprog file1.o file2.o
Note: It is possible to mix program and and other IPA modes using the command-line tool options. To mix modes in the plug-in compiler you will have to use " #pragma ipa".
Related information
-inline
-O
-O+
-opt