-qalias

Category

Optimization and tuning

Pragma equivalent

None

Purpose

Indicates whether a program contains certain categories of aliasing or does not conform to C standard aliasing rules. The compiler limits the scope of some optimizations when there is a possibility that different names are aliases for the same storage location.

Syntax

Read syntax diagramSkip visual syntax diagram
                  .-:---------------.   
                  | .-notypeptr---. |   
                  | +-restrict----+ |   
                  | +-global------+ |   
                  | +-noallptrs---+ |   
                  | +-ansi--------+ |   
                  V +-noaddrtaken-+ |   
>>- -q--alias--=----+-addrtaken---+-+--------------------------><
                    +-noansi------+     
                    +-allptrs-----+     
                    +-noglobal----+     
                    +-norestrict--+     
                    '-typeptr-----'     

Defaults

Parameters

addrtaken | noaddrtaken
When addrtaken is in effect, variables are disjoint from pointers unless their address is taken. Any class of variable for which an address has not been recorded in the compilation unit is considered disjoint from indirect access through pointers.

When noaddrtaken is specified, the compiler generates aliasing based on the aliasing rules that are in effect.

allptrs | noallptrs
When allptrs is in effect, pointers are never aliased (this also implies -qalias=typeptr). Specifying allptrs is an assertion to the compiler that no two pointers point to the same storage location. These suboptions are only valid if ansi is also in effect.
ansi | noansi
When ansi is in effect, type-based aliasing is used during optimization, which restricts the lvalues that can be safely used to access a data object. This suboption has no effect unless you also specify an optimization option. You can specify the may_alias attribute for a type that is not subject to type-based aliasing rules.

When noansi is in effect, the optimizer makes worst case aliasing assumptions. It assumes that a pointer of a given type can point to an external object or any object whose address is already taken, regardless of type.

global | noglobal
When global is in effect, type-based aliasing rules are enabled during IPA link-time optimization across compilation units. Both -qipa and -qalias=ansi must be enabled for -qalias=global to take effect. Specifying noglobal disables type-based aliasing rules.

-qalias=global produces better performance at higher optimization levels and also better link-time performance. If you use -qalias=global, it is recommended that you compile as much as possible of the application with the same version of the compiler to maximize the effect of the suboption on performance.

restrict | norestrict
When restrict is in effect, optimizations for pointers qualified with the restrict keyword are enabled. Specifying norestrict disables optimizations for restrict-qualified pointers.

-qalias=restrict is independent from other -qalias suboptions. Using the -qalias=restrict option will usually result in performance improvements for code that uses restrict-qualified pointers. Note, however, that using -qalias=restrict requires that restricted pointers be used correctly; if they are not, compile-time and runtime failures may result. You can use norestrict to preserve compatibility with code compiled with versions of the compiler previous to V9.0.

typeptr | notypeptr
When typeptr is in effect, pointers to different types are never aliased. The typeptr suboption is valid only when ansi is also in effect. typeptr is more restrictive than ansi. When typeptr is in effect, pointers can only point to an object of the same type or a compatible type, and a char* dereference cannot alias any other types.
C++ only beginsIf you specify -qalias=typeptr with programs that include the C++ Standard Library, you might get undefined results.C++ only ends

Usage

-qalias makes assertions to the compiler about the code that is being compiled. If the assertions about the code are false, then the code that is generated by the compiler might result in unpredictable behavior when the application is run.

The following are not subject to type-based aliasing:

The -qalias=[no]ansi option replaces the deprecated -q[no]ansialias option. Use -qalias=[no]ansi in your new applications.

Predefined macros

None.

Examples

To specify worst-case aliasing assumptions when you compile myprogram.c, enter:
xlc myprogram.c -O -qalias=noansi

Related information