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

[Bug rtl-optimization/50938] New: x86 alloca adds 15 twice


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50938

             Bug #: 50938
           Summary: x86 alloca adds 15 twice
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: ian@airs.com


Using alloca on x86 requires that the return value be aligned to a 16-byte
(boundary).  So code needs to add 15 to the size and then do & ~15.  However,
compile this file:

extern void bar (char *);
void
foo (int n)
{
  bar (__builtin_alloca (n));
}

The generated code adds 30, not 15.  That is, the adjustment is made twice. 
This works but wastes stack space.

The code in allocate_dynamic_stack_space in explow.c has become rather
convoluted and needs to be cleaned up to make this work.  E.g., it does #if
defined (STACK_POINTER_OFFSET), but defaults.h ensures that
STACK_POINTER_OFFSET is always defined.


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