# Inlining Report

Function inlining can improve execution time by removing the runtime overhead of function calls; however, function inlining can increase code size, code complexity, and compile times. In general, when you instruct the compiler to perform function inlining, the compiler examines the source code in a much larger context, and the compiler can find more opportunities to apply optimizations.

The Inlining Report is part of the Opt Report. The compiler options `-qopt-report` (Linux* and macOS) and `/Qopt-report` (Windows*) generate optimization reports with different levels of detail. Related compiler options, listed under Optimization Report Options, allow you to specify the phase, direct output to a specific file, `stdout` or `stderr`, and request reports from all routines with names containing a specific string as part of their name.

The inlining report is a description of the inlining choices that were made for each routine that is compiled in the program. It is produced as part of the opt report. To restrict the opt report to contain ONLY the inlining report, use the option `-qopt-report-phase=ipo` (Linux* and macOS) or `/Qopt-report-phase:ipo` (Windows*).

The user can control the amount of information by specifying a level for the inlining report. The level is shown by a number from 1 to 5. Level 1 contains the smallest amount of information, and each level adds information to the report. Level 2 is the default report.

Level | Summary
--- | ---
Level 1 | Shows each call that was inlined
Level 2 (default report) | Shows the values of the key inlining options
Level 3 | Shows the calls to routines with external linkage
Level 4 | Shows: Whole program information Size (sz) of the each routine inlined and the increase in application size (isz) due to each instance of inlining Routine percentages Calls that are not inlined
Level 5 | Shows inlining footnotes, which contain advice on how to change the inlining to potentially improve application performance

The inlining report gives you an in-depth overview of the compiler's inlining decisions, which occur within five levels of granularity. You can specify levels with -`qopt-report=1`, `-qopt-report=2`, etc., (Linux* and macOS) or `/Qopt-report=1`, `/Qopt-report=2`, etc. (Windows*). See below for specific level details.

## Level 1

The Inlining Report is activated when you run the Optimization Report, using `[q or Q]qopt-report`.

For each routine you compile, you get one report with the title INLINE REPORT that shows the calls inlined into that routine.

Example: Inlining Report Level 1 - Typical Routine
    INLINE REPORT: (APPLU)
      -> INLINE: (295,12) SETBV
        -> INLINE: (398,18) EXACT
        -> INLINE: (399,18) EXACT
        -> INLINE: (409,18) EXACT
        -> INLINE: (410,18) EXACT
        -> INLINE: (420,18) EXACT
        -> INLINE: (421,18) EXACT
      -> INLINE: (299,12) SETIV
      -> (303,12) ERHS
      -> (307,12) SSOR
      -> INLINE: (311,12) ERROR
        -> INLINE: (1518,24) EXACT
        -> INLINE: (1552,24) EXACT
      -> INLINE: (315,12) PINTGR
      -> (319,12) VERIFY

The report gives the name of the compiled routine (APPLU), and contains one line for each call that the compiler decided to inline or not inline. In the above report, the compiler made 15 inlining decisions for calls in the routine APPLU. It decided to inline 12 of the calls. These decisions are indicated by the lines which start with `-> INLINE`. It decided not to inline three of the calls. These decisions are indicated by the lines without the word INLINE.

On each line, the position of the call in the source code is given in parentheses, followed by the name of the routine being called. For example:

    -> INLINE: (398,18) EXACT

This refers to a call at line 398 column 18 to a routine called EXACT.

## Level 2

Level 2 includes the values of important compiler options related to inlining. Unless the user specifies one of these values by using the option on the command line, the default value of the option in shown. You can read more about the meaning of the individual inlining options in the Inlining Options section.

Example: Inlining Report Level 2 - Values of Inlining Options
    INLINING OPTION VALUES:
      -inline-factor: 100
      -inline-min-size: 30
      -inline-max-size: 230
      -inline-max-total-size: 2000
      -inline-max-per-routine: 10000
      -inline-max-per-compile: 500000

## Level 3

Level 3 contains one additional line for each call to an external routine made in the application. Such calls are not candidates for inlining, because the code for these routines is not present in the file or files being compiled.

Example: Inlining Report Level 3 - External Linkage
    Begin optimization report for: APPLU
    	Report from: Interprocedural optimizations [ipo]
    INLINE REPORT: (APPLU) [1] applu.f (1,16)
       -> EXTERN: (1,16) for_set_reentrancy
       -> EXTERN: (80,7) for_read_seq_lis

## Level 4

Level 4 adds four additional pieces of information. The specifics are shown below:

- Whole Program values:

  Example: Whole Program
      WHOLE PROGRAM [SAFE] [EITHER METHOD]: false
      WHOLE PROGRAM [SEEN] [TABLE METHOD]: true
      WHOLE PROGRAM [READ] [OBJECT READER METHOD]: false

  An application for which whole program is determined is subject to a higher degree of optimization than one which is not. The Intel compiler uses two methods of determining whole program, a TABLE METHOD and an OBJECT READER METHOD.

- The size of the routine [sz] and the inlined size of the routine [isz]. Usually isz is less than sz:

  Example: Size of the Routine (sz) vs. Inlined Size of the Routine (isz)
       -> INLINE: (295,12) SETBV (isz = 752) (sz = 755)
         -> INLINE: (398,18) EXACT (isz = 98) (sz = 109)

  In the above example, the routine SETBV was inlined into the routine that called it. The size of SETBV, before inlining, was 755 units. After inlining, the calling routine was increased by 752 units. The increase in the size of the calling routine is slightly less than the size of SETBV, because some of the overhead of calling SETBV was removed when SETBV was inlined.

- The percentage of time that has passed in the process of compiling the file:

  Example: Percentage of Time Passed During Compilation
      INLINE REPORT: (APPLU) [1/16=6.2%] applu.f (1,16)

  For example, on the line above, [1/16 = 6.2%] indicates that APPLU is the first routine out of 16 to be compiled, and when this routine is done being compiled, 6.2% of the compilation is finished. You can use these numbers to estimate how long the compilation is going to take.

- The calls that did not get inlined and the reason why they did not get inlined. The reason is shown in double brackets [[ ]].

  Example: Calls That Are Not Inlined
      -> (303,12) ERHS (isz = 2125) (sz = 2128)
         [[ Inlining would exceed –inline-max-size value (2128>253)]]

  In the above example, the routine ERHS is not inlined, because the size of the routine (2128 units) is larger than the allowable size (253 units). If you wish to inline routines that are this large, you can use the option `-inline-max-size=2128` (or larger).

## Level 5

Level 5 adds the inlining footnotes.

Example: Use of Footnote
    -> (303,12) ERHS (isz = 2058) (sz = 2061)
       [[ Inlining would exceed –inline-max-size-value (2061>230) <1>]]

The inlining footnotes explain the text found in the double brackets [[ ]]. They include a description for why an inlining call did not happen, and what you can do to make the inlining of this call happen.

The footnote annotation <1> refers to the first footnote in the INLINING FOOTNOTES section at the bottom of the inlining report, which is produced when the user selects Level 5. For example, the footnote produced for annotation <1> above is:

Example: Footnote Text
    <1> The subprogram is larger than the inliner would normally inline. Use the
    option –inline-max-size to increase the size of any subprogram that would
    normally be inlined, add “!DIR$ATTRIBUTES FORCELINE” to the
    declaration of the called function, or add “!DIR$ FORCELINE” before
    the call site.

Parent topic: Interprocedural Optimization