This qualifier tells KAP what level of data aliasing (the use of multiple names for the same memory location) may be present in the program. When there might be multiple ways for the same variable to be referenced, KAP is more cautious about transforming the code in ways which might change the order in which variables and arrays are used.
The associated pragma #pragma _KAP arl=<n>
has the
same meaning. The command qualifier is equivalent to a pragma at the
beginning of the file, and is thus overridden by other pragmas later
in the file.
The meanings of the individual levels are as follows:
0
- KAP makes no assumptions about data
aliasing.
1
- The default setting indicates that
a pointer will not contain its own address. This avoids the
uncommon problem in loops such as the following:
int *p; ... for ( i=0; i<n; i++ ) { p[i] = a[i]; }
Since p[0]
may be &p
, there are
dependences from the first iteration to the other iterations.
2
- This level indicates that none of the
objects represented by the function parameters overlap in memory.
This is not generally true for C functions, and by default KAP
will assume there is parameter aliasing. This is equivalent to a
#pragma _KAP distinct
for all parameters.
3
- This level indicates that global data,
function parameters, and local variables form distinct groups.
In other words, the memory locations referred to using local
variables will be different from the memory locations referred
to using global variables, and both of these will be different
from the memory locations referred to through parameters. For
example, level 3
would indicate that the arrays
a
, f
, and x
are distinct
as follows:
#pragma _KAP arl=3 float *a; f(x) float x[100]; { int i; float f[100]; for ( i=0; i<100; i++ ) { a[i] = x[i] + f[i]; } }
4
- This level asserts that there are no
aliases for objects. If pointers are used, there is never more
than one name used to reference an object.