Lists identifiers that are not aliased to each other within the scope of their use.
By informing the compiler that none of the identifiers listed in the pragma shares the same physical storage, the pragma provides more opportunity for optimizations.
>>-#pragma disjoint---------------------------------------------> .------------------------------. V | >--(--+--------+--variable_name----,--+--------+--variable_name-+--)->< | .----. | | .----. | | V | | | V | | '--- *-+-' '--- *-+-'
The #pragma disjoint directive asserts that none of the identifiers listed in the pragma share physical storage; if any the identifiers do actually share physical storage, the pragma may give incorrect results.
The pragma can appear anywhere in the source program that a declaration is allowed. An identifier in the directive must be visible at the point in the program where the pragma appears.
You must declare the identifiers before using them in the pragma. Your program must not dereference a pointer in the identifier list nor use it as a function argument before it appears in the directive.
This pragma can be disabled with the -qignprag compiler option.
int a, b, *ptr_a, *ptr_b;
#pragma disjoint(*ptr_a, b) /* *ptr_a never points to b */
#pragma disjoint(*ptr_b, a) /* *ptr_b never points to a */
one_function()
{
b = 6;
*ptr_a = 7; /* Assignment will not change the value of b */
another_function(b); /* Argument "b" has the value 6 */
}
External pointer ptr_a does not share
storage with and never points to the external variable b.
Consequently, assigning 7 to the object to which ptr_a points
will not change the value of b. Likewise, external
pointer ptr_b does not share storage with and never
points to the external variable a. The compiler can
assume that the argument to another_function has
the value 6 and will not reload the variable from memory.