This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcc restores wrong stack pointer value?


On 03/03/2011 09:55 AM, DJ Delorie wrote:
> So... gcc assumes the register push/pops happen before the frame
> pointer is initialized?  So the epilog always restores $sp from $fp
> before restoring registers?

Ah, I see you're one of the rare ! EXIT_IGNORE_STACK targets.

There does seem to be an off-by-one problem in the insertion
of the emit_stack_save code.  I'll work on it.

All that said, I can't imagine that !EXIT_IGNORE_STACK is actually
more efficient than doing the right thing in the epilogue for any
target.

In the case of m32c, sure for very small functions you'll get

	enter
	pushm
	mov	sp,a0
	...
	mov	a0,sp
	popm
	exitd

However, there are very very few registers on this target, and
it seems exceedingly likely that any address register used here
will get spilled.  At which point you have a pair of load/store
insns added to spill that value.

Compare that to

	enter
	pushm
	...
	mova	ofs[fb],a0
	mov	a0,sp
	popm
	exitd

which never needs the pair of spill insns.  Something to consider...


r~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]