summaryrefslogtreecommitdiff
path: root/lib/Bitcode/Reader
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2012-06-23 11:37:03 +0000
committerHans Wennborg <hans@hanshq.net>2012-06-23 11:37:03 +0000
commitce718ff9f42c7da092eaa01dd0242e8d5ba84713 (patch)
treed3c6b996686af3fc9f47f7b5407c773a86a4f653 /lib/Bitcode/Reader
parent47cbc4e0ee6098b7be3c60108000a979f1809949 (diff)
downloadllvm-ce718ff9f42c7da092eaa01dd0242e8d5ba84713.tar.gz
llvm-ce718ff9f42c7da092eaa01dd0242e8d5ba84713.tar.bz2
llvm-ce718ff9f42c7da092eaa01dd0242e8d5ba84713.tar.xz
Extend the IL for selecting TLS models (PR9788)
This allows the user/front-end to specify a model that is better than what LLVM would choose by default. For example, a variable might be declared as @x = thread_local(initialexec) global i32 42 if it will not be used in a shared library that is dlopen'ed. If the specified model isn't supported by the target, or if LLVM can make a better choice, a different model may be used. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159077 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bitcode/Reader')
-rw-r--r--lib/Bitcode/Reader/BitcodeReader.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp
index 83756daa7a..4a20b1c9d6 100644
--- a/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -102,6 +102,17 @@ static GlobalValue::VisibilityTypes GetDecodedVisibility(unsigned Val) {
}
}
+static GlobalVariable::ThreadLocalMode GetDecodedThreadLocalMode(unsigned Val) {
+ switch (Val) {
+ case 0: return GlobalVariable::NotThreadLocal;
+ default: // Map unknown non-zero value to general dynamic.
+ case 1: return GlobalVariable::GeneralDynamicTLSModel;
+ case 2: return GlobalVariable::LocalDynamicTLSModel;
+ case 3: return GlobalVariable::InitialExecTLSModel;
+ case 4: return GlobalVariable::LocalExecTLSModel;
+ }
+}
+
static int GetDecodedCastOpcode(unsigned Val) {
switch (Val) {
default: return -1;
@@ -1544,9 +1555,10 @@ bool BitcodeReader::ParseModule(bool Resume) {
GlobalValue::VisibilityTypes Visibility = GlobalValue::DefaultVisibility;
if (Record.size() > 6)
Visibility = GetDecodedVisibility(Record[6]);
- bool isThreadLocal = false;
+
+ GlobalVariable::ThreadLocalMode TLM = GlobalVariable::NotThreadLocal;
if (Record.size() > 7)
- isThreadLocal = Record[7];
+ TLM = GetDecodedThreadLocalMode(Record[7]);
bool UnnamedAddr = false;
if (Record.size() > 8)
@@ -1554,12 +1566,11 @@ bool BitcodeReader::ParseModule(bool Resume) {
GlobalVariable *NewGV =
new GlobalVariable(*TheModule, Ty, isConstant, Linkage, 0, "", 0,
- isThreadLocal, AddressSpace);
+ TLM, AddressSpace);
NewGV->setAlignment(Alignment);
if (!Section.empty())
NewGV->setSection(Section);
NewGV->setVisibility(Visibility);
- NewGV->setThreadLocal(isThreadLocal);
NewGV->setUnnamedAddr(UnnamedAddr);
ValueList.push_back(NewGV);