Restore stack_pointer_delta for allocate_stack on s390
Fixes incorrect stack pointer delta leakage on s390, preventing incorrect function-entry probes.
A bug in the allocate_dynamic_stack_space function on s390, when using the -mbackchain option, caused the stack_pointer_delta to be incorrectly modified and not restored. This was because the expander allocate_stack became available, bypassing the normal saving and restoring mechanism for stack_pointer_delta. The leaked value interfered with function-entry probes generated by -fstack-check, leading to incorrect REG_ARGS_SIZE notes in the generated assembly. This fix ensures stack_pointer_delta is correctly managed, even when the expander is used.
In Details
On s390 with -mbackchain, allocate_dynamic_stack_space uses the allocate_stack expander. This expander indirectly calls anti_adjust_stack(), which modifies stack_pointer_delta. However, the saving and restoring of stack_pointer_delta were conditional on allocate_stack *not* being available. This commit corrects the logic to ensure stack_pointer_delta is saved and restored even when the expander is used, preventing the leaked value from corrupting REG_ARGS_SIZE notes in function-entry probes emitted by expand_function_end() via anti_adjust_stack_and_probe().
- stack_pointer_delta
- A variable or register that tracks the difference between the current stack pointer and the original stack pointer at the beginning of a function. It's used for managing stack frames and allocating local variables.
- allocate_stack
- An expander or intrinsic function used by the compiler to allocate space on the call stack for local variables or temporary data.
- s390
- A family of mainframe mainframe computer architectures developed by IBM.
- -mbackchain
- A GCC compiler flag for the s390 architecture that enables the use of backchains in stack frames, a mechanism for linking frames for debugging and exception handling.
- -fstack-check
- A GCC compiler flag that enables runtime checks for stack overflow conditions. This often involves inserting probes at function entry and exit.
- REG_ARGS_SIZE
- A machine-dependent note or attribute associated with an assembly instruction, indicating the size of arguments passed on the stack for a function call. Incorrect values can lead to stack corruption or incorrect function linkage.