User`s guide

Recommended and Required Source Changes
3.1 Stack Usage
3.1.1 References to the Procedure Stack Frame
The compiler disallows references to positive stack offsets from FP, and flags them
as errors. A single exception to this rule is the practice whereby VAX MACRO
code establishes a dynamic condition handler by moving a routine address to
the stack location pointed to by FP. The compiler detects this and generates the
appropriate Alpha or Itanium code for establishing such a handler. However,
if the write to 0(FP) occurs inside a JSB routine, the compiler will flag it as an
error. The compiler allows negative FP offsets, as used for referring to stack
storage allocated at procedure entry.
Recommended Change
If possible, remove stack frame references entirely rather than convert to the
OpenVMS Alpha or OpenVMS I64 format. For example, if the offending code
was attempting to change saved register values, store the new value in a stack
temporary and set the register value on routine exit (removing the register from
the entry register mask).
3.1.2 References Outside the Current Stack Frame
By monitoring stack depth throughout a VAX MACRO module, the compiler
detects references in a routine to data pushed on the stack by its caller and flags
them as errors.
Recommended Change
You must eliminate references in a routine to data pushed on the stack by its
caller. Instead, pass the required data as parameters or pass a pointer to the
stack base from which the data can be read.
3.1.3 Nonaligned Stack References
At routine calls, the compiler octaword-aligns the stack, if the stack is not already
octaword-aligned. Some code, when building structures on the stack, makes
unaligned stack references or causes the stack pointer to become unaligned. The
compiler flags both of these with information-level messages.
Recommended Change
Provide sufficient padding in data elements or structures pushed onto the stack,
or change data structure sizes. Because unaligned stack references also have an
impact on VAX performance, you should apply these fixes to code designed for the
VAX, Alpha, and Itanium architectures.
3.1.4 Building Data Structures on the Stack
A common coding practice is to produce a structure on the stack by pushing the
elements and relying on auto decrement to move the stack pointer to allocate
space. The problems with this technique follow:
If the SDL source for the structure being built is modified to pad the structure
in order to align fields, the code will be broken. If the code does not contain
assume statements this will not be detected at compile time.
If the size of a field is extended, the current instruction will not access all the
data and this will also go undetected.
3–2 Recommended and Required Source Changes