#pragma isolated_call

Description

The #pragma isolated_call directive marks a function that does not have or rely on side effects, other than those implied by its parameters.

Syntax

Read syntax diagramSkip visual syntax diagram>>-#--pragma--isolated_call--(--function--)--------------------><

where function is a primary expression that can be an identifier, operator function, conversion function, or qualified name. An identifier must be of type function or a typedef of function. If the name refers to an overloaded function, all variants of that function are marked as isolated calls.

Notes

The -qisolated_call compiler option has the same effect as this pragma.

The pragma informs the compiler that the function listed does not have or rely on side effects, other than those implied by its parameters. Functions are considered to have or rely on side effects if they:

Essentially, any change in the state of the runtime environment is considered a side effect. Modifying function arguments passed by pointer or by reference is the only side effect that is allowed. Functions with other side effects can give incorrect results when listed in #pragma isolated_call directives.

Marking a function as isolated_call indicates to the optimizer that external and static variables cannot be changed by the called function and that pessimistic references to storage can be deleted from the calling function where appropriate. Instructions can be reordered with more freedom, resulting in fewer pipeline delays and faster execution in the processor. Multiple calls to the same function with identical parameters can be combined, calls can be deleted if their results are not needed, and the order of calls can be changed.

The function specified is permitted to examine non-volatile external objects and return a result that depends on the non-volatile state of the runtime environment. The function can also modify the storage pointed to by any pointer arguments passed to the function, that is, calls by reference. Do not specify a function that calls itself or relies on local static storage. Listing such functions in the #pragma isolated_call directive can give unpredictable results.

The -qignprag compiler option causes aliasing pragmas to be ignored. Use the -qignprag compiler option to debug applications containing the #pragma isolated_call directive.

Example

The following example shows the use of the #pragma isolated_call directive. Because the function this_function does not have side effects, a call to it will not change the value of the external variable a. The compiler can assume that the argument to other_function has the value 6 and will not reload the variable from memory.

int a;

// Assumed to have no side effects
int this_function(int);
	
#pragma isolated_call(this_function)
that_function()
{
   a = 6;
   // Call does not change the value of "a"
   this_function(7);

   // Argument "a" has the value 6
   other_function(a);
}

Related information