i386.c (ix86_compute_frame_layout): Do add bottom alignment for alloca.

* config/i386/i386.c (ix86_compute_frame_layout): Do add bottom
        alignment for alloca.

	* gcc.c-torture/execute/alloca-1.c: New.

From-SVN: r54018
This commit is contained in:
Richard Henderson 2002-05-29 13:29:21 -07:00 committed by Richard Henderson
parent edfe859577
commit 002ff5bc3e
3 changed files with 29 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2002-05-29 Richard Henderson <rth@redhat.com>
* config/i386/i386.c (ix86_compute_frame_layout): Do add bottom
alignment for alloca.
2002-05-29 Richard Henderson <rth@redhat.com>
* config/i386/i386.c (output_pic_addr_const): Lowercase rip.

View File

@ -4148,8 +4148,9 @@ ix86_compute_frame_layout (frame)
else
frame->outgoing_arguments_size = 0;
/* Align stack boundary. Only needed if we're calling another function. */
if (!current_function_is_leaf)
/* Align stack boundary. Only needed if we're calling another function
or using alloca. */
if (!current_function_is_leaf || current_function_calls_alloca)
frame->padding2 = ((offset + preferred_alignment - 1)
& -preferred_alignment) - offset;
else

View File

@ -0,0 +1,21 @@
/* Verify that alloca storage is sufficiently aligned. */
/* ??? May fail if BIGGEST_ALIGNMENT > STACK_BOUNDARY. Which, I guess
can only happen on !STRICT_ALIGNMENT targets. */
typedef __SIZE_TYPE__ size_t;
struct dummy { int x __attribute__((aligned)); };
#define BIGGEST_ALIGNMENT __alignof__(struct dummy)
_Bool foo(void)
{
char *p = __builtin_alloca(32);
return ((size_t)p & (BIGGEST_ALIGNMENT - 1)) == 0;
}
int main()
{
if (!foo())
abort ();
return 0;
}