This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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]

Re: [PATCH v2] Clean up check_pf allocation pattern. addresses


On Wed, May 28, 2014 at 01:02:10PM +0200, Andreas Schwab wrote:
> OndÅej BÃlka <neleai@seznam.cz> writes:
> 
> > No, that would not be problem if gcc optimized alloca alignment which it
> > does not do now.
> 
> What do you mean with "alloca alignment"?
> 
How that does expand in assembly, you need to align pointers to 16
bytes. A following fragment 

int main()
{
  char *x = alloca (42);
  foo (x);
}

with stack pointer named sp growing downward gets expanded to

int main()
{
 register char *tmp = sp;
 sp -= 64;
 char *x = (sp + 15) & (-16);
 foo (x);
 sp = tmp;
}

but when there is array 

int main()
{
  char *x[42];
  foo (x);
}

then code becomes

int main()
{
  sp -= 56;
  x = sp;
  foo (x);
  sp += 56;
}


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