SLAU132V October   2004  – February 2020

 

  1.   1
    1.     2
    2.     3
    3.     4
    4.     5
    5.     6
  2.   7
    1.     8
    2.     9
    3.     10
    4.     11
    5.     12
  3.   13
    1.     14
    2.     15
    3.     16
      1.      17
      2.      18
      3.      19
      4.      20
      5.      21
      6.      22
      7.      23
      8.      24
      9.      25
      10.      26
      11.      27
      12.      28
    4.     29
      1.      30
      2.      31
    5.     32
      1.      33
      2.      34
        1.       35
      3.      36
      4.      37
      5.      38
      6.      39
      7.      40
      8.      41
      9.      42
      10.      43
    6.     44
    7.     45
      1.      46
      2.      47
    8.     48
    9.     49
    10.     50
    11.     51
      1.      52
      2.      53
    12.     54
      1.      55
    13.     56
    14.     57
  4.   58
    1.     59
    2.     60
    3.     61
      1.      62
    4.     63
      1.      64
      2.      65
    5.     66
    6.     67
      1.      68
      2.      69
    7.     70
      1.      71
        1.       72
        2.       73
        3.       74
        4.       75
        5.       76
        6.       77
        7.       78
        8.       79
      2.      80
      3.      81
      4.      82
    8.     83
      1.      84
        1.       85
        2.       86
      2.      87
        1.       88
        2.       89
        3.       90
    9.     91
    10.     92
    11.     93
      1.      94
      2.      95
    12.     96
    13.     97
      1.      98
      2.      99
      3.      100
      4.      101
      5.      102
      6.      103
      7.      104
      8.      105
      9.      106
      10.      107
      11.      108
      12.      109
      13.      110
  5.   111
    1.     112
      1.      113
      2.      114
      3.      115
    2.     116
      1.      117
      2.      118
    3.     119
      1.      120
        1.       121
          1.        122
        2.       123
        3.       124
      2.      125
      3.      126
      4.      127
      5.      128
      6.      129
      7.      130
      8.      131
      9.      132
        1.       133
  6.   134
    1.     135
      1.      136
    2.     137
    3.     138
    4.     139
    5.     140
    6.     141
      1.      142
    7.     143
    8.     144
      1.      145
      2.      146
      3.      147
        1.       148
        2.       149
      4.      150
        1.       151
    9.     152
    10.     153
    11.     154
    12.     155
      1.      156
      2.      157
      3.      158
      4.      159
      5.      160
      6.      161
        1.       162
        2.       163
        3.       164
        4.       165
      7.      166
      8.      167
        1.       168
        2.       169
        3.       170
      9.      171
      10.      172
      11.      173
      12.      174
      13.      175
      14.      176
      15.      177
      16.      178
      17.      179
      18.      180
      19.      181
      20.      182
      21.      183
      22.      184
      23.      185
      24.      186
      25.      187
      26.      188
      27.      189
      28.      190
      29.      191
      30.      192
        1.       193
        2.       194
        3.       195
      31.      196
      32.      197
    13.     198
    14.     199
    15.     200
    16.     201
      1.      202
      2.      203
      3.      204
    17.     205
      1.      206
      2.      207
      3.      208
      4.      209
      5.      210
    18.     211
  7.   212
    1.     213
      1.      214
      2.      215
      3.      216
      4.      217
      5.      218
      6.      219
    2.     220
      1.      221
        1.       222
        2.       223
        3.       224
        4.       225
      2.      226
    3.     227
    4.     228
      1.      229
      2.      230
      3.      231
    5.     232
    6.     233
      1.      234
      2.      235
        1.       236
        2.       237
      3.      238
        1.       239
          1.        240
          2.        241
        2.       242
          1.        243
          2.        244
      4.      245
      5.      246
    7.     247
      1.      248
      2.      249
      3.      250
      4.      251
      5.      252
    8.     253
      1.      254
      2.      255
      3.      256
      4.      257
        1.       258
          1.        259
        2.       260
          1.        261
    9.     262
      1.      263
      2.      264
      3.      265
        1.       266
        2.       267
        3.       268
        4.       269
          1.        270
          2.        271
          3.        272
          4.        273
        5.       274
        6.       275
      4.      276
        1.       277
        2.       278
    10.     279
  8.   280
    1.     281
      1.      282
      2.      283
      3.      284
      4.      285
      5.      286
      6.      287
      7.      288
      8.      289
    2.     290
      1.      291
        1.       292
      2.      293
      3.      294
      4.      295
        1.       296
      5.      297
        1.       298
    3.     299
    4.     300
      1.      301
      2.      302
        1.       303
        2.       304
          1.        305
          2.        306
          3.        307
          4.        308
      3.      309
        1.       310
        2.       311
  9.   312
    1.     313
    2.     314
      1.      315
      2.      316
      3.      317
  10.   318
    1.     319
  11.   320
    1.     321

Using Inline Function Expansion

When an inline function is called, a copy of the C/C++ source code for the function is inserted at the point of the call. This is known as inline function expansion, commonly called function inlining or just inlining. Inline function expansion can speed up execution by eliminating function call overhead. This is particularly beneficial for very small functions that are called frequently. Function inlining involves a tradeoff between execution speed and code size, because the code is duplicated at each function call site. Large functions that are called in many places are poor candidates for inlining.

NOTE

Excessive Inlining Can Degrade Performance

Excessive inlining can make the compiler dramatically slower and degrade the performance of generated code.

Function inlining is triggered by the following situations:

  • The use of built-in intrinsic operations. Intrinsic operations look like function calls, and are inlined automatically, even though no function body exists.
  • Use of the inline keyword or the equivalent __inline keyword. Functions declared with the inline keyword may be inlined by the compiler if you set --opt_level=0 or greater. The inline keyword is a suggestion from the programmer to the compiler. Even if your optimization level is high, inlining is still optional for the compiler. The compiler decides whether to inline a function based on the length of the function, the number of times it is called, your --opt_for_speed setting, and any contents of the function that disqualify it from inlining (see Section 2.11.2). Functions can be inlined at --opt_level=0 or above if the function body is visible in the same module or if -pm is also used and the function is visible in one of the modules being compiled. Functions may be inlined at link time if the file containing the definition and the call site were both compiled with --opt_level=4. Functions defined as both static and inline are more likely to be inlined.
  • When --opt_level=3 or greater is used, the compiler may automatically inline eligible functions even if they are not declared as inline functions. The same list of decision factors listed for functions explicitly defined with the inline keyword is used. For more about automatic function inlining, see Section 3.5.
  • The pragma FUNC_ALWAYS_INLINE (Section 5.12.12) and the equivalent always_inline attribute (Section 5.17.2) force a function to be inlined (where it is legal to do so) unless --opt_level=off. That is, the pragma FUNC_ALWAYS_INLINE forces function inlining even if the function is not declared as inline and the --opt_level=0 or --opt_level=1.
  • The FORCEINLINE pragma (Section 5.12.10) forces functions to be inlined in the annotated statement. That is, it has no effect on those functions in general, only on function calls in a single statement. The FORCEINLINE_RECURSIVE pragma forces inlining not only of calls visible in the statement, but also in the inlined bodies of calls from that statement.
  • The --disable_inlining option prevents any inlining. The pragma FUNC_CANNOT_INLINE prevents a function from being inlined. The NOINLINE pragma prevents calls within a single statement from being inlined. (NOINLINE is the inverse of the FORCEINLINE pragma.)

NOTE

Function Inlining Can Greatly Increase Code Size

Function inlining increases code size, especially inlining a function that is called in a number of places. Function inlining is optimal for functions that are called only from a small number of places and for small functions.

The semantics of the inline keyword in C code follow the C99 standard. The semantics of the inline keyword in C++ code follow the C++ standard.

The inline keyword is supported in all C++ modes, in relaxed ANSI mode for all C standards, and in strict ANSI mode for C99 and C11. It is disabled in strict ANSI mode for C89, because it is a language extension that could conflict with a strictly conforming program. If you want to define inline functions while in strict ANSI C89 mode, use the alternate keyword __inline.

Compiler options that affect inlining are: --opt_level, --auto_inline, --remove_hooks_when_inlining, --opt_for_speed, and --disable_inlining.