* Allow preferred-stack-boundary of 3 for x86-64
@ 2007-07-24 0:54 Jan Hubicka
2007-07-27 22:33 ` Andi Kleen
0 siblings, 1 reply; 3+ messages in thread
From: Jan Hubicka @ 2007-07-24 0:54 UTC (permalink / raw)
To: gcc-patches, ak
Hi,
Andi Kleen raised point that while x86-64 ABI requires 16byte alignment,
kernel preffers to save stack psace by 8 byte alignment even though it
breaks some of features (such as XMM support or variadic arguments of
types aligned to 16 bytes, such as long double).
This patch thus makes GCC to tolerate this option and updates
documentation accrodingly. I will install it tomorrow if there are no
complains. Bootstrapped/regtested i686-linux.
Honza
* i386.c (override_options): Allow preferred stack boundary of 3 for x86-64.
* doc/invoke.texi (preferred-stack-boundary): Document.
Index: config/i386/i386.c
===================================================================
*** config/i386/i386.c (revision 126800)
--- config/i386/i386.c (working copy)
*************** override_options (void)
*** 2324,2332 ****
if (ix86_preferred_stack_boundary_string)
{
i = atoi (ix86_preferred_stack_boundary_string);
! if (i < (TARGET_64BIT ? 4 : 2) || i > 12)
error ("-mpreferred-stack-boundary=%d is not between %d and 12", i,
! TARGET_64BIT ? 4 : 2);
else
ix86_preferred_stack_boundary = (1 << i) * BITS_PER_UNIT;
}
--- 2324,2332 ----
if (ix86_preferred_stack_boundary_string)
{
i = atoi (ix86_preferred_stack_boundary_string);
! if (i < (TARGET_64BIT ? 3 : 2) || i > 12)
error ("-mpreferred-stack-boundary=%d is not between %d and 12", i,
! TARGET_64BIT ? 3 : 2);
else
ix86_preferred_stack_boundary = (1 << i) * BITS_PER_UNIT;
}
Index: doc/invoke.texi
===================================================================
*** doc/invoke.texi (revision 126800)
--- doc/invoke.texi (working copy)
*************** libraries that use callbacks always use
*** 10323,10329 ****
This extra alignment does consume extra stack space, and generally
increases code size. Code that is sensitive to stack space usage, such
as embedded systems and operating system kernels, may want to reduce the
! preferred alignment to @option{-mpreferred-stack-boundary=2}.
@item -mmmx
@itemx -mno-mmx
--- 10323,10337 ----
This extra alignment does consume extra stack space, and generally
increases code size. Code that is sensitive to stack space usage, such
as embedded systems and operating system kernels, may want to reduce the
! preferred alignment to @option{-mpreferred-stack-boundary=2}
! or @option{-mpreferred-stack-boundary=3}.
!
! The 64bit SYSV ABI require at lest 16-byte alignment. Specifying
! @option{-mpreferred-stack-boundary=3} is accepted by compiler, but will result
! in misaligning the stack. Calling functions with misaligned stack will break
! spilling of SSE registers as well as varargs of types with 16-byte alignment.
! It may be however viable alternative for stack space constrained environments.
!
@item -mmmx
@itemx -mno-mmx
Index: config/i386/i386.h
===================================================================
*** config/i386/i386.h (revision 126800)
--- config/i386/i386.h (working copy)
*************** extern const char *host_detect_local_cpu
*** 775,781 ****
/* Target OS keeps a vector-aligned (128-bit, 16-byte) stack. This is
mandatory for the 64-bit ABI, and may or may not be true for other
operating systems. */
! #define TARGET_KEEPS_VECTOR_ALIGNED_STACK TARGET_64BIT
/* Minimum allocation boundary for the code of a function. */
#define FUNCTION_BOUNDARY 8
--- 775,782 ----
/* Target OS keeps a vector-aligned (128-bit, 16-byte) stack. This is
mandatory for the 64-bit ABI, and may or may not be true for other
operating systems. */
! #define TARGET_KEEPS_VECTOR_ALIGNED_STACK \
! (TARGET_64BIT && ix86_preferred_stack_boundary >= 4)
/* Minimum allocation boundary for the code of a function. */
#define FUNCTION_BOUNDARY 8
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Allow preferred-stack-boundary of 3 for x86-64
2007-07-24 0:54 Allow preferred-stack-boundary of 3 for x86-64 Jan Hubicka
@ 2007-07-27 22:33 ` Andi Kleen
2007-07-31 5:03 ` Jan Hubicka
0 siblings, 1 reply; 3+ messages in thread
From: Andi Kleen @ 2007-07-27 22:33 UTC (permalink / raw)
To: Jan Hubicka; +Cc: gcc-patches
On Tuesday 24 July 2007 01:05:03 Jan Hubicka wrote:
> Hi,
> Andi Kleen raised point that while x86-64 ABI requires 16byte alignment,
> kernel preffers to save stack psace by 8 byte alignment even though it
> breaks some of features (such as XMM support or variadic arguments of
> types aligned to 16 bytes, such as long double).
>
> This patch thus makes GCC to tolerate this option and updates
> documentation accrodingly. I will install it tomorrow if there are no
> complains. Bootstrapped/regtested i686-linux.
I tested the patch now and I get a ICE while compiling the x86_64 linux kernel
with -mpreferred-stack-boundary=3 and 070727 SVN checkout + patch
/home/lsrc/quilt/linux/init/do_mounts.c: In function 'change_floppy':
/home/lsrc/quilt/linux/init/do_mounts.c:390: internal compiler error: in ix86_compute_frame_layout, at config/i386/i386.c:5745
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Test case is in http://www.firstfloor.org/~andi/do_mounts.i
Compile with -mpreferred-stack-boundary=3 -Os
-Andi
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Allow preferred-stack-boundary of 3 for x86-64
2007-07-27 22:33 ` Andi Kleen
@ 2007-07-31 5:03 ` Jan Hubicka
0 siblings, 0 replies; 3+ messages in thread
From: Jan Hubicka @ 2007-07-31 5:03 UTC (permalink / raw)
To: Andi Kleen; +Cc: Jan Hubicka, gcc-patches
>
> I tested the patch now and I get a ICE while compiling the x86_64 linux kernel
> with -mpreferred-stack-boundary=3 and 070727 SVN checkout + patch
>
> /home/lsrc/quilt/linux/init/do_mounts.c: In function 'change_floppy':
> /home/lsrc/quilt/linux/init/do_mounts.c:390: internal compiler error: in ix86_compute_frame_layout, at config/i386/i386.c:5745
Hi,
this patch should fix it, I will commit it after testing on
x86_64-linux.
Honza
* i386.c (setup_incoming_varargs_64): Tolerate 64bit preferred
stack boundary.
Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c (revision 127065)
+++ config/i386/i386.c (working copy)
@@ -4656,7 +4656,14 @@ setup_incoming_varargs_64 (CUMULATIVE_AR
/* Indicate to allocate space on the stack for varargs save area. */
ix86_save_varrargs_registers = 1;
- cfun->stack_alignment_needed = 128;
+ /* We need 16-byte stack alignment to save SSE registers. If user
+ asked for lower preferred_stack_boundary, lets just hope that he knows
+ what he is doing and won't varargs SSE values.
+
+ We also may end up assuming that only 64bit values are stored in SSE
+ register let some floating point program work. */
+ if (ix86_preferred_stack_boundary >= 128)
+ cfun->stack_alignment_needed = 128;
save_area = frame_pointer_rtx;
set = get_varargs_alias_set ();
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-07-31 3:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-24 0:54 Allow preferred-stack-boundary of 3 for x86-64 Jan Hubicka
2007-07-27 22:33 ` Andi Kleen
2007-07-31 5:03 ` Jan Hubicka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).