------- Additional Comments From uros at kss-loka dot si  2004-12-14 06:38 
-------
(In reply to comment #25)
> I have been completely unable to reproduce an unaligned stack, with either 3.4
> or 4.0.  Can those gcc folk that claim to have reproduced it in the past still
> do so?  If so, what are you trying?

Testcase 1 (without threads):

--cut here--
float hmag[128],hphase[128];
void prepare(float *oscilFFTfreqs)
{
          int i;
            for (i=0;i<128;i++)
                 *oscilFFTfreqs=-hmag[i]*sin(hphase[i])/2.0;
}
--cut here--

Compile it with 'gcc -O2 msse2':

...
prepare:
        pushl   %ebp
        movl %esp, %ebp
        pushl   %esi
        pushl   %ebx
        xorl %ebx, %ebx
        subl $64, %esp
        movss   .LC0, %xmm0
        movl 8(%ebp), %esi
        movaps  %xmm0, -40(%ebp)     <- here, load from unaligned stack
        .p2align 4,,15
.L2:
...

Testcase 2: (with threads):

--cut here--
/* *** start ***/
#include <pthread.h>
#include <stdio.h>
#include <assert.h>

#include <xmmintrin.h>
#include <mmintrin.h>

#ifdef __ICC
#include <emmintrin.h>
#endif

void * f(void *p)
{
          int x = (p == NULL) ? 0 : * (int *) p;
            __m128i s;
              printf("&x = %p &s= %p\n", &x, &s);
                return NULL;
}

int main(int argc, char ** argv)
{
          pthread_t th;

            f(& argc);
              assert(pthread_create(& th, NULL, f, &argc)==0);
                assert(pthread_join(th, NULL)==0);
           return 0;
}

/* ***end ***/

gcc -O2 -msse2 -lpthread:
./a.out
&x = 0xbffff9cc &s= 0xbffff9b0
&x = 0x4085fac8 &s= 0x4085faac   <- here, s is not aligned correctly

It is a question whether ifor pthreads a stack alignment code should be present
in the function (that would be more robust), or it is a libc's job to provide
correctly alligned stack.

I think that summary of this bugreport is not correct now.

-- 


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

Reply via email to