When we generate code for upward growing stack on x86 target, the stack pointer (SP) is adjusted at the beginning of all functions to bypass the return address (refer to this article). However, when a sibling function is called the control is transfered to the function using a jump instruction rather than a "call", which means that no return address is inserted on the stack. In these cases, we should "anti_adjust" (decrement, in our case) the SP before the jump in order to compensate the value added to the SP at the beginning of the function.
I made gcc insert the code to decrement the SP when emitting a call to a sibling function, but it muddled the stack offset computation in restoring saved registers. I removed the code and added it to the epilogue expansion. This works flawlessly.
Monday, September 3, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment