B.2.67 -xalias_level[=l]
The compiler uses
the -xalias_level option to determine what assumptions
it can make in order to perform optimizations using type-based alias-analysis.
This option places the indicated alias level into effect for the translation
units being compiled.
If you do not specify the -xalias_level command,
the compiler assumes -xalias_level=any. If you specify -xalias_level without a value, the default is -xalias_level=layout.
The -xalias_level option requires optimization level -xO3 or above. If optimization is set lower, a warning is issued
and the -xalias_level option is ignored.
Remember that if you issue the -xalias_level option
but you fail to adhere to all of the assumptions and restrictions about aliasing
described for any of the alias levels, the behavior of your program is undefined.
Replace l with one of the terms in the following
table.
Table B–11 The Levels of Alias-Disambiguation
Flag
|
Meaning
|
any
|
The compiler assumes that all memory references can alias at this
level. There is no type-based alias analysis at the level of -xalias_level=any.
|
basic
|
If you use the -xalias_level=basic option,
the compiler assumes that memory references that involve different C basic
types do not alias each other. The compiler also assumes that references to
all other types can alias each other as well as any C basic type. The compiler
assumes that references using char * can alias any other
type.
For example, at the -xalias_level=basic level, the
compiler assumes that a pointer variable of type int * is not going to access a float object. Therefore it is safe for
the compiler to perform optimizations that assume a pointer of type float * will not alias the same memory that is referenced
with a pointer of type int *.
|
weak
|
If you use the -xalias_level=weak option,
the compiler assumes that any structure pointer can point to any structure
type.
Any structure or union type that contains a reference to any type that
is either referenced in an expression in the source being compiled or is referenced
from outside the source being compiled, must be declared prior to the expression
in the source being compiled.
You can satisfy this restriction by including all the header files of
a program that contain types that reference any of the types of the objects
referenced in any expression of the source being compiled.
At the level of -xalias_level=weak, the compiler
assumes that memory references that involve different C basic types do not
alias each other. The compiler assumes that references using char
* alias memory references that involve any other type.
|
layout
|
If you use the -xalias_level=layout option,
the compiler assumes that memory references that involve types with the same
sequence of types in memory can alias each other.
The compiler assumes that two references with types that do not look
the same in memory do not alias each other. The compiler assumes that any
two memory accesses through different struct types alias if the initial members
of the structures look the same in memory. However, at this level, you should
not use a pointer to a struct to access some field of a dissimilar struct
object that is beyond any of the common initial sequence of members that look
the same in memory between the two structs. This is because the compiler assumes
that such references do not alias each other.
At the level of -xalias_level=layout the compiler
assumes that memory references that involve different C basic types do not
alias each other. The compiler assumes that references using char
* can alias memory references involving any other type.
|
strict
|
If you use the -xalias_level=strict option,
the compiler assumes that memory references, that involve types such as structs
or unions, that are the same when tags are removed, can alias each other.
Conversely, the compiler assumes that memory references involving types that
are not the same even after tags are removed do not alias each other.
However, any structure or union type that contains a reference to any
type that is part of any object referenced in an expression in the source
being compiled, or is referenced from outside the source being compiled, must
be declared prior to the expression in the source being compiled.
You can satisfy this restriction by including all the header files of
a program that contain types that reference any of the types of the objects
referenced in any expression of the source being compiled. At the level of -xalias_level=strict the compiler assumes that memory references
that involve different C basic types do not alias each other. The compiler
assumes that references using char * can alias any other
type.
|
std
|
If you use the -xalias_level=std option,
the compiler assumes that types and tags need to be the same to alias, however,
references using char * can alias any other type. This
rule is the same as the restrictions on the dereferencing of pointers that
are found in the 1999 ISO C standard. Programs that properly use this rule
will be very portable and should see good performance gains under optimization.
|
strong
|
If you use the -xalias_level=strong option,
the same restrictions apply as at the std level, but additionally,
the compiler assumes that pointers of type char * are used
only to access an object of type char. Also, the compiler assumes that there
are no interior pointers. An interior pointer is defined as a pointer that
points to a member of a struct.
|