summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2002-05-29 20:29:21 +0000
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2002-05-29 20:29:21 +0000
commit3ad630c5db254d7ea2b6c0a2a6184ce0867ee0c1 (patch)
tree0a9bd5d94ab8f9e568b01c40c442821c3c32f51e
parentcc79d0fab21cebbeef5841c2d0a48600b89080b9 (diff)
downloadgcc-3ad630c5db254d7ea2b6c0a2a6184ce0867ee0c1.tar.gz
* config/i386/i386.c (ix86_compute_frame_layout): Do add bottom
alignment for alloca. * gcc.c-torture/execute/alloca-1.c: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@54018 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/config/i386/i386.c5
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/alloca-1.c21
3 files changed, 29 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a7619317330..14069a7f6b1 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,10 @@
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.
(print_operand_address): Only add rip for symbolic addresses
for which we do not have another relocation type.
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 5170c99a4c8..877f3554ffb 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -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
diff --git a/gcc/testsuite/gcc.c-torture/execute/alloca-1.c b/gcc/testsuite/gcc.c-torture/execute/alloca-1.c
new file mode 100644
index 00000000000..a8d1384c6ec
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/alloca-1.c
@@ -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;
+}