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

Re: Misalignment of local SSE variables in thread function


Brian Dessent writes:
 > Andrew Haley wrote:
 > 
 > >  > So, neither CreateThread nor MSVCRT align the stack, so I guess you'll
 > >  > have to do it yourself.  You should be able to do this with something
 > >  > like:
 > >  >
 > >  >   asm  __volatile__  ("andl $-16, %%esp" : : : "%esp");
 > >  >
 > >  > at the beginning of your thread function.
 > > 
 > > Ouch.  I don't think that would work.
 > 
 > It looked a little iffy to me too, but I copied it directly from mingw's
 > crt1.c where it has this comment:
 > 
 >   /* Align the stack to 16 bytes for the sake of SSE ops in main
 >      or in functions inlined into main.  */

I think that's a special case: it's written with carnal knowledge of
the state at the time.  I guess the clobber of SP doesn't cause the
compiler to reload SP from BP+offset, but I don't know why it doesn't.

In any case, it's rather hairy.  :-)

Andrew.


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