On Tue, 2015-08-11 at 10:05 +0930, Alan Modra wrote: > > The 'and' instruction is where the stack gets aligned and if I remove that > > one instruction, everything works. I think I need to put out some new CFI > > psuedo-ops to handle this but I am not sure what they should be. I am just > > not very familiar with the CFI directives. > > I don't speak mips assembly very well, but it looks to me that you > have more than just CFI problems. How do you restore sp on return > from the function, assuming sp wasn't 16-byte aligned to begin with? > Past that "and $sp,$sp,$3" you don't have any means of calculating > the original value of sp! (Which of course is why you also can't find > a way of representing the frame address.)
I have code in expand_prologue that copies the incoming stack pointer to a temporary hard register and then I have code to the entry_block to copy that register into a virtual register. In the exit block that virtual register is copied back to a temporary hard register and expand_epilogue copies it back to $sp to restore the stack pointer. This function (fn2) ends with a call to abort, which is noreturn, so the optimizer sees that the epilogue is dead code and GCC determines that there is no need to save the old stack pointer since it will never get restored. I guess I need to tell GCC to save the stack pointer in expand_prologue even if it never sees a use for it. I guess I need to make the temporary register where I save $sp volatile or do something else so that the assignment (and its associated .cfi) is not deleted by the optimizer. Steve Ellcey sell...@imgtec.com