3.6.6.22 Reorder-stack-vars Option

The -mreorder-stack-vars option picks the optimal set of stack variables to allocate in the first 63 bytes of the stack (the maximum offset addressable via the frame pointer). It aims to minimize expensive frame pointer adjustment code before and after access to stack variables that are positioned outside that range. The primary intent of this feature is to reduce code size—however, the execution speed of the generated code will also likely improve—but the optimal choice that minimizes code size could result in a frequently used object being placed outside the range accessible by the frame pointer. This feature is automatically enabled at optimization level -O2 and above.

The -mno-reorder-stack-vars form of this option disables the reordering of items in the local frame, having objects allocated stack offsets in the default order dictated by GCC for the currently selected options.