Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
Parallel Programming Guide for HP-UX Systems: K-Class and V-Class Servers > Chapter 7 Controlling optimization

C aliasing options

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

The optimizer makes a conservative assumption that a pointer can point to any object in the entire application. Command-line options to the C compiler are available to inform the optimizer of an application's pointer usage. Using this information, the optimizer can generate more efficient code, due to the elimination of some false assumptions.

You can direct pointer behavior to the optimizer by using the following options:

  • + O[no]ptrs_strongly_typed

  • + O[no]ptrs_to_globals[=namelist]

  • + O[no]global_ptrs_unique[=namelist]

  • + O[no]ptrs_ansi

where

namelist

is a comma-separated list of global variable names.

The following are type-inferred aliasing rules that apply when using these +O optimization options:

  • Type-aliasing optimizations are based on the assumption that pointer dereferences obey their declared types.

  • A C variable is considered address-exposed if and only if the address of that variable is assigned to another variable or passed to a function as an actual parameter. In general, address-exposed objects are collected into a separate group, based on their declared types. Global and static variables are considered address-exposed by default. Local variables and actual parameters are considered address-exposed only if their addresses have been computed using the address operator &.

  • Dereferences of pointers to a certain type are assumed to only alias with the corresponding equivalent group. An equivalent group includes all the address-exposed objects of the same type. The dereferences of pointers are also assumed to alias with other pointer dereferences associated with the same group.

    For example, in the following line:

    int *p, *q;

    *p and *q are assumed to alias with any objects of type int. Also, *p and *q are assumed to alias with each other.

  • Signed/unsigned type distinctions are ignored in grouping objects into an equivalent group. Likewise, long and int types are considered to map to the same equivalent group. However, the volatile type qualifier is considered significant in grouping objects into equivalent groups. For example, a pointer to int is not considered to alias with a volatile int object.

  • If two type names reduce to the same type, they are considered synonymous.

    In the following example, both types type_old and type_new reduce to the same type, struct foo.

    typedef struct foo_st type_old;
    typedef type_old type_new;
  • Each field of a structure type is placed in a separate equivalent group that is distinct from the equivalent group of the field's base type. The assumption here is that a pointer to int is not assigned the address of a structure field whose type is int. The actual type name of a structure type is not considered significant in constructing equivalent groups. For example, dereferences of a struct foo pointer and a struct bar pointer is assumed to alias with each other even if struct foo and struct bar have identical field declarations.

  • All fields of a union type are placed in the same equivalent group, which is distinct from the equivalent group of any of the field's base types. This means that all dereferences of pointers to a particular union type are assumed to alias with each other, regardless of which union field is being accessed.

  • Address-exposed array variables are grouped into the equivalent group of the array element type.

  • Applying an explicit pointer typecast to an expression value causes any later use of the typecast expression value to be associated with the equivalent group of the typecast expression value.

    For example, an int pointer typecast into a float pointer and then dereferenced is assumed to potentially access objects in the float equivalent group—and not the int equivalent group.

    However, type-incompatible assignments to pointer variables do not alter the aliasing assumptions on subsequent references of such pointer variables.

    In general, type-incompatible assignments can potentially invalidate some of the type-safe assumptions. Such constructs may elicit compiler warning messages.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© Hewlett-Packard Development Company, L.P.