[cft] aligning main's stack frame
Richard Henderson
rth@redhat.com
Mon Oct 17 19:15:00 GMT 2005
On Mon, Oct 17, 2005 at 12:25:46PM +0200, Andi Kleen wrote:
> > main:
> > leal 4(%esp), %ecx # create argument pointer
> > andl $-16, %esp # align stack
> > pushl -4(%ecx) # copy return address
>
> This will misaligned the call/ret stack in the CPU, leading to branch
> mispredictions on many of the following RETs. On main it's probably
> not a big issue, but for other functions it might be.
No it won't. I don't actually use that for the return insn.
I cheat and move the CFA, and that copy satisfies the return
address at CFA-4 during the body of the function.
r~
More information about the Gcc
mailing list