HP 3000 Manuals

When to Use the Optimizer [ HP Pascal/iX Programmer's Guide ] MPE/iX 5.0 Documentation


HP Pascal/iX Programmer's Guide

When to Use the Optimizer 

Compile your program with optimization only after you have debugged it.
The optimizer can transform error-free programs only.

A warning indicates a possible source of run-time errors.  If compiling
your program produces warnings, do one of the following:

   *   Be sure that your program will never satisfy the conditions that
       the warnings specify (see the next example).

   *   Change your program so that compiling it does not produce
       warnings.

When you request optimization, the compiler issues warnings for local
variables that are used before they are initialized.

Example 

     FUNCTION f (p : integer) : integer;

     VAR
        v : integer;

     BEGIN
        f := p;

        IF p < 0 THEN
           f := v;
     END;

The preceding program causes the compiler to issue the warning ACCESSED,
BUT NOT INITIALIZED (535), which applies to the variable v.  A run-time
error occurs if v is accessed.  If you are sure p will never have a value
less than zero, you can ignore the warning, because the run-time error
will never occur.

If you are sure that your program will never produce an out-of-range
error, specify RANGE OFF before compiling it with optimization.  When the
compiler does not generate range-checking code, it compiles faster and
can perform more optimizations.  The compiled program runs faster without
range-checking code, whether or not it is optimized.  (See the HP 
Pascal/iX Reference Manual or the HP Pascal/HP-UX Reference Manual,
depending on your implementation, for information on the RANGE compiler
option.)

Once you have compiled your program with optimization, you cannot use the
symbolic debugger to debug it, because:

   *   Debug information will be missing from it (the compiler cannot
       generate debug information and perform optimizations at the same
       time).

   *   Level two optimization radically reorders the code, sometimes
       keeping in registers the values of variables that you may want to
       examine.



MPE/iX 5.0 Documentation