This is the mail archive of the 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]

[Bug c/33484] New: -mpreferred-stack-boundary=num is ignored if num > 4

According to the man page, -mpreferred-stack-boundary allows one to specify
what the stack is aligned at.
"Attempt to keep the stack boundary aligned to a 2 raised to num byte boundary.
 If -mpreferred-stack-boundary is not specified, the default is 4 (16 bytes or
128 bits)."

# gcc -mpreferred-stack-boundary=7  -mstackrealign testme.c -o ttt3.s -S
In ttt3.s you will see:
        leal    4(%esp), %ecx
        andl    $-16, %esp
        pushl   -4(%ecx)

        leal    4(%esp), %ecx
        andl    $-128, %esp
        pushl   -4(%ecx)

No matter which value is passed to -mpreferred-stack-boundary (if it's larger
than 4), it will always align the stack to 16 bytes.

Fix (diff according to svn):
diff -urN gcc/gcc/config/i386/i386.c stack-boundary-fix/gcc/config/i386/i386.c
--- gcc/gcc/config/i386/i386.c  2007-09-19 00:37:00.000000000 +0200
+++ stack-boundary-fix/gcc/config/i386/i386.c   2007-09-19 01:06:57.000000000
@@ -6242,7 +6242,7 @@

       /* Align the stack.  */
       emit_insn (gen_andsi3 (stack_pointer_rtx, stack_pointer_rtx,
-                            GEN_INT (-16)));
+                            GEN_INT

       /* And here we cheat like madmen with the unwind info.  We force the
         cfa register back to sp+4, which is exactly what it was at the

           Summary: -mpreferred-stack-boundary=num is ignored if num > 4
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: yyounan at fort-knox dot org
 GCC build triplet: i386-linux-gnu
  GCC host triplet: i386-linux-gnu
GCC target triplet: i386-linux-gnu

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