[LLVMdev] Bug Report -- Possible optimizer bug with thread_local variables

Caldarale, Charles R Chuck.Caldarale at unisys.com
Thu Nov 8 04:33:49 PST 2012


> From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu]
> On Behalf Of Tom Bergan
> Subject: [LLVMdev] Bug Report -- Possible optimizer bug with thread_local variables

> my current workaround is to declare Ptr volatile:
>    int * volatile Ptr;

> Note that if the volatile is moved under the pointer, as in the following:
>    volatile int * Ptr;

> then the bug reappears, as the load "*Ptr" in main() will be incorrectly optimized to:
>    %5 = load volatile i32* @Foo, align 4

Discounting the TLS problem, the above observed behavior is correct.  Setting volatile between the * and Ptr informs the compiler that Ptr may vary; setting volatile before int indicates what Ptr points to may vary.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.





More information about the llvm-dev mailing list