[LLVMdev] Bug Report -- Possible optimizer bug with thread_local variables
Hans Wennborg
hans at chromium.org
Fri Nov 9 11:23:11 PST 2012
Hi Tom,
On Wed, Nov 7, 2012 at 11:43 PM, Tom Bergan <tbergan at cs.washington.edu> wrote:
> Hello,
>
> I apologize if this has already been fixed or reported. I believe there is
> a bug in the way the optimizer deals with thread_local variables. The
> attached program, test.c, has a thread-local variable "int Foo" and a global
> variable "int *Ptr". The program takes the following steps:
>
> 1) The main thread spawns a new thread and waits
> 2) The new thread writes Foo = 50 and Ptr = &Foo, then signals the main
> thread and waits
> 3) The main thread prints *Ptr, releases the new thread, and exits
>
> The crux of this example is that the main thread obtains a pointer to the
> new thread's TLS via "Ptr". When I compile with gcc, the program prints
> "50" as expected. When I compile with LLVM, the program prints "0". This
> is confirmed in the following three versions of LLVM:
> * the 2.9 release
> * whatever version of LLVM is driving http://llvm.org/demo/index.cgi
> * svn revision 167568 on trunk (this was the most-recent revision as of a
> few hours ago)
I tried your test.c, compiled with "clang -O3", but couldn't reproduce
the error you're seeing. (I was using revison 167547).
What flags did you use when you compiled locally?
Thanks,
Hans
More information about the llvm-dev
mailing list