This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: CFI directives and dynamic stack alignment
- From: Steve Ellcey <sellcey at imgtec dot com>
- To: Alan Modra <amodra at gmail dot com>
- Cc: "<gcc at gcc dot gnu dot org>" <gcc at gcc dot gnu dot org>
- Date: Mon, 24 Aug 2015 15:25:05 -0700
- Subject: Re: CFI directives and dynamic stack alignment
- Authentication-results: sourceware.org; auth=none
- References: <1438638489 dot 8302 dot 14 dot camel at ubuntu-sellcey> <20150811003543 dot GH26017 at bubble dot grove dot modra dot org> <1439833102 dot 16261 dot 16 dot camel at ubuntu-sellcey> <20150817235341 dot GE4378 at bubble dot grove dot modra dot org>
- Reply-to: <sellcey at imgtec dot com>
On Tue, 2015-08-18 at 09:23 +0930, Alan Modra wrote:
> On Mon, Aug 17, 2015 at 10:38:22AM -0700, Steve Ellcey wrote:
> OK, then you need to emit a .cfi directive to say the frame top is
> given by the temp hard reg sometime after that assignment and before
> sp is aligned in the prologue, and another .cfi directive when copying
> to the pseudo. It's a while since I looked at the CFI code in gcc,
> but arranging this might be as simple as setting RTX_FRAME_RELATED_P
> on the insns involved.
>
> If -fasynchronous-unwind-tables, then you'll also need to track the
> frame in the epilogue.
>
> > 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.
>
> Ah, I see. Yes, the temp and pseudo are not really dead if they are
> needed for unwinding.
Yes, I was originally thinking I just had to make the temp and pseudo
regs volatile so that the assignments would not get removed but it
appears that I need the epilogue code too (even if I never get there
because of a call to abort which GCC knows is non-returning) so that I
have the needed .cfi directives there. I am thinking I should add an
edge from the entry_block to the exit_block so that the exit block is
never removed by the optimizer. I assume this edge would need to be
abnormal and/or fake but I am not sure which (if either) of these edges
would be appropriate for this.
Steve Ellcey
sellcey@imgtec.com