Make GlobalOpt be conservative with TLS variables (PR14309)
authorHans Wennborg <hans@hanshq.net>
Thu, 15 Nov 2012 11:40:00 +0000 (11:40 +0000)
committerHans Wennborg <hans@hanshq.net>
Thu, 15 Nov 2012 11:40:00 +0000 (11:40 +0000)
commit709e015cf170dd056806001b22f7da2c3e9154a7
tree0e2a6342ec7c3af530dfcd78a14997b5ac4ca5e5
parenta4d31a33b5e2e443176c789ad4bc4583134e148b
Make GlobalOpt be conservative with TLS variables (PR14309)

For global variables that get the same value stored into them
everywhere, GlobalOpt will replace them with a constant. The problem is
that a thread-local GlobalVariable looks like one value (the address of
the TLS var), but is different between threads.

This patch introduces Constant::isThreadDependent() which returns true
for thread-local variables and constants which depend on them (e.g. a GEP
into a thread-local array), and teaches GlobalOpt not to track such
values.

llvm-svn: 168037
llvm/include/llvm/Constant.h
llvm/lib/Transforms/IPO/GlobalOpt.cpp
llvm/lib/VMCore/Constants.cpp
llvm/test/Transforms/GlobalOpt/tls.ll [new file with mode: 0644]