Optimizes out TLS variable called in a child function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



During my adventures in wine and gcc5 I've had to compile updated wine-gecko and wine-mono binaries as they get updated at various periods alongside wine. I encountered an issue with gcc5 not compiling a TLS routine in wine-mono. I created a simple test case and can see the same failure result with the test case in gcc 4.8 and 4.9 as well as 5. My test case may be doing something wrong, and if it is I may be able to fix wine-mono, but the test case fails in a suspiciously single way that looks like a gcc bug.

The attached test case is getting the offset location of a TLS variable. When compiled with -O0 the test case compiles. When compiled with -O1 the test case will not compile with an error for an undefined reference to the TLS variable. If you move the THREAD_VAR_OFFSET macro call to main() gcc will compile without error. Any suggestions?

Thanks,
Michael

#define THREAD_VAR_OFFSET(var,offset) do { long int foo; __asm ("movq " #var "@GOTTPOFF(%%rip), %0" : "=r" (foo)); offset = foo; } while ( 0 )

static __thread void *foo_tls;


int foo( void )
{
    int offset;

    THREAD_VAR_OFFSET( foo_tls, offset );

    return offset;
}


int main( int argc, char *argv[] )
{
    foo(  );

    return 0;
}

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux