HP C Programmer's Guide (92434-90009)

Chapter 4 103
Optimizing HP C Programs
Optimizer Pragmas
and return the pointer that malloc() or calloc() returns. For example, in the program
below:
struct_type *get_new_record(void)
{
struct_type *p;
if ((p=malloc(sizeof(*p))) == NULL) {
printf("get_new_record():out of memory\n");
abort();
}
else {
/* initialize the struct */
º
return p;
}
the routine get_new_record falls under this category, and can be included in the
ALLOCS_NEW_MEMORY pragma.
FLOAT_TRAPS_ON pragma
Informs the compiler that the function(s) may enable floating-point trap handling. When
the compiler is so informed, it will not perform loop invariant code motion (LICM) on
floating-point operations in the function(s) named in the pragma. This pragma is required
for proper code generation when floating-point traps are enabled.
[#pragma FLOAT_TRAPS_ON {
functionname,...functionname
_ALL}]
For example:
#pragma FLOAT_TRAPS_ON xyz,abc
informs the compiler and optimizer that xyz and abc have floating-point traps turned on
and therefore LICM optimization should not be performed.
[NO]PTRS_STRONGLY_TYPED Pragma
The PTRS_STRONGLY_TYPED pragma allows you to specify when a subset of types are
type-safe. This provides a finer lever of control than +O[no]ptrs_strongly_typed.
#pragma PTRS_STRONGLY_TYPED BEGIN
#pragma PTRS_STRONGLY_TYPED END
#pragma NOPTRS_STRONGLY_TYPED BEGIN
#pragma NOPTRS_STRONGLY_TYPED END
Any types that are defined between the begin-end pair are taken to apply type-safe
assumptions. These pragmas are not allowed to nest. For each BEGIN an associated END
must be defined in the compilation unit.
The pragma will take precedence over the command line option. Although, sometimes both
are required (see example 2).