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
HP Integrity Servers: HP aC++/HP ANSI C Release Notes > Chapter 2 What’s New in This Version

New Features in Version A.06.15

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Index

Version A.06.15 of the HP aC++ compiler supports the following new features:

  • printf(), fprintf() Optimization (New)

  • +Wmacro Option (New)

  • +Wcontext_limit Option (New)

  • +wperfadvice Option (New)

  • +Wv Option (New)

  • +wlock (New)

  • +O[no]autopar Option (New)

  • +O[no]loop_block Option (New)

  • +O[no]loop_unroll_jam (Default Changed)

  • +Olit=all is the new default for HP C (Change)

  • +macro_debug= Option (New)

  • +pathtrace Option (New)

  • +check Suboptions (New)

  • -Bhidden_def Option (New)

  • -dM Option (New)

  • #pragma OPT_LEVEL INITIAL (New)

  • #pragma OPTIMIZE (Deprecated)

  • #pragma [NO]INLINE (New for C++ mode)

  • _Asm_ld, _Asm_ldf, _Asm_st, _Asm_stf intrinsics added (New)

  • Debugging code compiled with opt levels above +O1 now supported (New)

printf, fprintf Optimization (New)

For optimization level +O2 or above, printf() and fprintf() calls are now optimized into fputc() or fputs() calls, in trivial cases.Restrictions for the optimization to occur:

  • A return value cannot be used for printf() and fprintf(). For example, use (void)fprintf(...);

  • The functions printf(), fprintf(), fputs(), and fputc() must be declared in <stdio.h> or <cstdio>.

To disable this feature for +O2 and above, use: +Onolibcalls="fprintf" (or "printf").

To have the compiler list the lines where the optimization was performed, use +Oinfo.

+Wmacro Option (New)

+Wmacro:MACRONAME:d1,d2,...,dn

The +Wmacro option disables warning diagnostics d1,d2,...,dn in the expansion of macro MACRONAME. If -1 is given as the warning number, then all warnings are suppressed. This option is not applicable to warning numbers greater than 20000. +Wmacro gets higher priority than the other diagnostic control command-line options that are applicable to the whole source. Diagnostic control pragmas take priority based on where they are placed.

+Wcontext_limit Option (New)

+Wcontext_limit=num

This option limits the number of instantiation contexts output by the compiler for diagnostics involving template instantiations. At most num outermost contexts and num innermost contexts are shown. If there are more than 2 * num relevant contexts, the additional contexts are omitted. Omitted contexts are replaced by a single line separating the outermost num contexts from the innermost num contexts, and indicating the number of contexts omitted. The default value for num is 5. A value of 0 removes the limit.

+wperfadvice Option (New)

+wperfadvice[={1|2|3|4}]

This option enables performance advisory messages. The optional level 1, 2, 3, or 4 controls how verbosely the performance advisory messages are emitted. The higher the level, the more messages are generated. Level 1 emits only the most important messages, while level 4 emits all the messages. If the optional level is not specified, it defaults to 2.

+Wv Option (New)

+Wv[d1,d2,...,dn]

The new +Wv option displays the description for diagnostic message numbers d1,d2,...,dn.

Specifying this option causes HP Code Advisor to emit the descriptive text for the specified diagnostics to stderr. This option must not be used with any other compiler options.

If the description for a diagnostic is not available, HP Code Advisor emits only the diagnostic with a note that the description is not available.

+wlock Option (New)

+wlock

This option enables compile-time diagnostic messages for potential errors in using lock/unlock calls in programs that use pthread library based lock/unlock functions. Warnings are emitted for acquiring an already acquired lock, releasing an already released lock, and unconditionally releasing a lock that has been conditionally acquired.

This diagnostic checking is based on cross-module analysis performed by the compiler. Therefore, the +wlock option implicitly enables a limited form of cross-module analysis, even if -ipo or +O4 options are not specified. This can lead to a significant increase in the compile time compared to a build without the +wlock option. Using this option could result in the compiler invoking optimizations other than those that are part of the user-specified optimization level. If +wlock is used in addition to -ipo or +O4, the generated code is not affected, and the compile time does not increase much.

+O[no]autopar Option (New)

+O[no]autopar

This release adds support on the Itanium platform for a new optimization -auto-parallelization - which is enabled by adding the +Oautopar option to the command-line. This optimization allows applications to exploit otherwise idle resources on multicore or multiprocessor systems by automatically transforming serial loops into multithreaded parallel code.

When the +Oautopar option is used at optimization levels +O3 and above, the compiler will automatically parallelize those loops that are deemed safe and profitable by the loop transformer.

The default is +Onoautopar, which disables automatic parallelization of loops.

Automatic parallelization can be combined with manual parallelization through the use of OpenMP directives and the +Oopenmp option. When both +Oopenmp and +Oautopar options are specified, the compiler honors the OpenMP directives first, and then looks for loops that have not been parallelized manually with OpenMP directives. For these loops, the compiler automatically parallelizes each loop that is both safe and likely to have improved performance when executed in parallel.

Programs compiled with the +Oautopar option require the libcps, libomp, and libpthreads runtime support libraries to be present at both compilation and runtime. When linking with the HP-UX B.11.61 linker (patch PHSS_36342 or PHSS_36349), compiling with the +Oautopar option causes them to be automatically included. Older linkers require those libraries to be specified explicitly or by compiling with +Oopenmp.

At present, +Oautopar is only supported when compiling C or Fortran files, and not C++ files. If you use +Oautopar with C or Fortran code in a mixed-language application that also includes C++ files, you must use +Oopenmp when compiling and linking the C++ files. Refer to the +Oopenmp documentation for additional information and restrictions.

+O[no]loop_block Option (New)

+O[no]loop_block

Loop blocking is a combination of strip mining and interchange that improves data cache locality. It is provided primarily to deal with nested loops that manipulate arrays that are too large to fit into the data cache. Under certain circumstances, loop blocking allows reuse of these arrays by transforming the loops that manipulate them so that they manipulate strips of the arrays that fit into the cache.

At optimization levels 3 and 4, using +Oloop_block (the default) allows automatic loop blocking. Specifying +Onoloop_block disables loop blocking.

+O[no]loop_unroll_jam (Default Change)

At optimization levels 3 and 4, the default for this option has changed from +Onoloop_unroll_jam to +Oloop_unroll_jam, which allows automatic loop unroll-and-jam.

+Olit=all (Default Change for HP C)

The default in C mode of the compiler is now +Olit=all, placing string constants in read-only memory by default. This change over previous versions of the compiler (which defaulted to +Olit=const) improves performance and is in keeping with similar changes in the industry. Note that this may cause a runtime signal 11 if an attempt is made to modify string literals.

To force the string to be read/write, you can change the source as follows:

static CHAR forall_00[] = "FORALL.CHARTYPE ";
static CHAR forall_01[] = "FORALL.COMPLEXTYPE ";
...
static CHAR *foralltemptypename[LASTINTRINTYPE-FIRSTINTRINTYPE+1] = {
   forall_00, forall_01, ...

Using an array will force the string to be read/write.

Other simpler cases can be handled as:
changing to array will work in most cases:
   char *temp = "abcd";
   char temp[] = "abcd";

If temp is used as a pointer:
   static char temp_arr[] = "abcd";
   char *temp = temp_arr;

+macro_debug= (New)

The +macro_debug option controls the emission of macro debug information into the object file:

+macro_debug={ref|all|none}

Set +macro_debug to one of the following required values:

ref

Emits debug information only for referenced macros. This is the default for -g, -g1, or -g0.

all

Emits debug information for all macros. This option can cause a significant increase in object file size.

none

Does not emit any macro debug information.

One of the -g options (-g, -g0, or -g1) must be used to enable the +macro_debug option.

+nomacro_debug suppresses emission of macro debug information into the object file.

+pathtrace (New)

+pathtrace[=kind]

The +pathtrace option provides a mechanism to record program execution control flow into global and/or local path tables. The saved information can be used by the HP WDB debugger to assist with crash path recovery from the core files, or to assist when debugging the program by showing the executed branches.

Usage:

The defined values for kind are:

local

Generates a local path table and records basic block-execution information in it at runtime.

global

Generates a global path table and records basic block-execution information in it at runtime.

global_fixed_size

Generates a fixed-size (65536 items) global path table and records basic block-execution information in it at runtime.

This form differs from +pathtrace=global because the size of the table cannot be configured at runtime, and the contents cannot be dumped to a file. The fixed-size global path table has better runtime performance than the configurable global path table. The performance difference varies depending on the optimization level and how the program is written.

none

Disables generation of both the global and local path tables.

The values can be combined by joining them with a colon. For example:

+pathtrace=global:local

The global_fixed_size and global values are mutually exclusive. If more than one of them are specified on the command line, the last one takes precedence. The same is true for the none value.

+pathtrace with no values is equivalent to +pathtrace=global_fixed_size:local.

The use of this option and the -mt option must be consistent for all compilation and link steps. That means if -mt is used with +pathtrace at compile time, it should also be used at link time; if -mt is not used with +pathtrace at compile time, it should not used at link time. Otherwise, a link-time error can occur.

+check Suboptions (New)

The following new suboptions have been added to the +check option:

+check=globals
+check=truncate[:explicit|:implicit]

The following new suboptions have been added to the +check=bounds option:

+check=bounds:array
+check=bounds:pointer
+check=bounds:all
+check=bounds:none

Descriptions:

  • +check=globals

    The +check=globals option enables runtime checks to detect corruption of global variables by introducing and checking "guards" between them, at the time of program exit. Setting environment variable RTC_ROUTINE_LEVEL_CHECK will also enable the check whenever a function compiled with this option returns.

    For this purpose, the definition of global is extended to be all variables that have static storage duration, including file or namespace scope variables, function scope static variables, and class (or template class) static data members.

    The +check=globals option is implied by +check=all.

  • +check=truncate[:explicit|:implicit]

    The +check=truncate option enables runtime checks to detect data loss in assignment when integral values are truncated. Data loss occurs if the truncated bits are not all the same as the left most non-truncated bit for signed type, or not all zero for unsigned type.

    Programs may contain intentional truncation at runtime, such as when obtaining a hash value from a pointer or integer. To avoid runtime failures on these truncations, the user can explicitly mask off the value:

    ch = (int_val & 0xff);

    +check=truncate:explicit turns on runtime checks for truncation on explicit user casts of integral values, such as (char)int_val.

    +check=truncate:implicit turns on runtime checks for truncation on compiler-generated implicit type conversions, such as ch = int_val;.

    +check=truncate turns on runtime checks for both explicit cast and implicit conversion truncation.

    Note that the +check=all option does not imply +check=truncate. To enable +check=truncate, you must explicitly specify it.

  • +check=bounds[:array|pointer|all|none]

    The +check=bounds option has been enhanced to provide the option of checking for out-of-bound references to buffers through pointer access as well as to array variables. You can specify one of the following +check=bounds suboptions:

    array

    Enables check for out-of-bounds references to array variables.

    pointer

    Enables check for out-of-bounds references to buffers through pointer access. The buffer could be a heap object, global variable, or local variable. This suboption also checks out-of-bounds access through common libc function calls such as strcpy, strcat, memset, and so on. This check can create significant run-time performance overhead.

    all

    Enables out-of-bounds checks for both arrays and pointers. This is equal to +check=bounds:array +check=bounds:pointer.

    none

    Disables out-of-bounds checks..

    +check=bounds (with no suboption) is equal to +check=bounds:array. This may change in the future to also include +check=bounds:pointer.

    When +check=all is specified, it enables +check=bounds:array only. To enable the pointer out-of-bounds check, +check=bounds:pointer must be specified explicitly.

-Bhidden_def (New)

-Bhidden_def

This option is the same as -Bhidden, but only locally defined (non-tentative) symbols, without __declspec(dllexport), are assigned the hidden export class.

As with any -B option, -Bhidden_def can be overridden by subsequent -B options on the command line or any binding pragmas in the source.

-dM (New)

-dM

The -dM option requires that -P or -E also be specified. When -dM is present, instead of normal preprocessor output the compiler lists the #define directives it encounters as it preprocesse the file, thus providing a list of all macros that are in effect at the start of the compilation.

A common use of this option is to determine the compiler's predefined macros. For example:

touch foo.c ; cc -E -dM foo.c

#pragma OPT_LEVEL INITIAL (New)

#pragma OPT_LEVEL INITIAL

#pragma OPT_LEVEL has been enhanced to accept an additional keyword, INITIAL .

When used with a numeric argument, the OPT_LEVEL pragma sets the optimization level to 0, 1, 2, 3, or 4.

The INITIAL argument causes the optimization level in effect at the start of the compilation, whether by default or specified on the command line, to be restored.

#pragma OPTIMIZE (Deprecated)

As of this release of the compiler, #pragma OPTIMIZE is deprecated. Use #pragma OPT_LEVEL instead.

#pragma [NO]INLINE (New for C++ Mode)

Previously, #pragma [NO]INLINE was supported only on HP C and aC++ C-mode. With this release, #pragma [NO]INLINE is now supported in C++ mode as well.

_Asm_ld, _Asm_ldf, _Asm_st, _Asm_stf Intrinsics Added (New)

The following new assembly intrinsics have been added to the compiler:

_Asm_ld _Asm_st

_Asm_ldf _Asm_stf

For more information, see the "Inline assembly for Itanium(R)-based HP-UX" link off http://www.hp.com/go/cpp.

Debugging Code Compiled with Opt Levels above +O1 Is Supported

Debugging code compiled with optimization levels above +O1 is now supported, as described in section 14.22 ("Debugging optimized code") of the Debugging with GDB manual under the "Documentation" link at: http://www.hp.com/go/wdb.

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