This is the mail archive of the gcc-help@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: Extra space allocated for array


On Sun, 2008-04-20 at 11:16 -0700, Brian Dessent wrote:

> The stack pointer is always kept aligned to 16 bytes so that functions
> that require it (e.g. those that use SIMD operands) don't have to emit
> instructions to align it in the prologue.
> 
> Brian

That's what I thought. But notice the prologue:
main:
	pushq	%rbp
	movq	%rsp, %rbp
	subq	$88, %rsp

Now the stack pointer is not on a 16-byte boundary.

Reading the ABI carefully (n+1 times), I see that it says that the
16-byte boundary for the stack is the condition upon entry to a
function. The easiest way to do this is to allocate local variable space
in multiples of 16 in the prologue. Since this function does not call a
function, my take is that the 16-byte rule does not apply.

I ran this in gdb, and sure enough, the stack pointer is at an 8-byte
boundary, not 16-byte.

-- Bob



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