Sun Studio 12: C++ User's Guide

A.2.127 -xinline[=func_spec[,func_spec...]]

Specifies which user-written routines can be inlined by the optimizer at -xO3 levels or higher.

A.2.127.1 Values

func_spec must be one of the following values.

Table A–34 The -xinline Values




Enable automatic inlining at optimization levels -xO4 or higher. This argument tells the optimizer that it can inline functions of its choosing. Note that without the %auto specification, automatic inlining is normally turned off when explicit inlining is specified on the command line by -xinline=[no%]func_name...


Strongly request that the optimizer inline the function. If the function is not declared as extern "C", the value of func_name must be mangled. You can use the nm command on the executable file to find the mangled function names. For functions declared as extern "C", the names are not mangled by the compiler.


When you prefix the name of a routine on the list with no%, the inlining of that routine is inhibited. The rule about mangled names for func_name applies to no%func_name as well.

Only routines in the file being compiled are considered for inlining unless you use -xcrossfile[=1]. The optimizer decides which of these routines are appropriate for inlining.


If the -xinline option is not specified, the compiler assumes -xinline=%auto.

If -xinline= is specified with no arguments, no functions are inlined, regardless of the optimization level.


To enable automatic inlining while disabling inlining of the function declared int foo(), use

example% CC -xO5 -xinline=%auto,no%__1cDfoo6F_i_ -c

To strongly request the inlining of the function declared as int foo(), and to make all other functions as the candidates for inlining, use

example% CC -xO5 -xinline=%auto,__1cDfoo6F_i_ -c

To strongly request the inlining of the function declared as int foo(), and to not allow inlining of any other functions, use

example% CC -xO5 -xinline=__1cDfoo6F_i_ -c


The -xinline option has no effect for optimization levels below -xO3. At -xO4 and higher, the optimizer decides which functions should be inlined, and does so without the -xinline option being specified. At -xO4 and higher, the compiler also attempts to determine which functions will improve performance if they are inlined.

A routine is not inlined if any of the following conditions apply. No warnings will be omitted.


If you force the inlining of a function with -xinline, you might actually diminish performance.

See Also

A.2.133 -xldscope={v}