diff options
author | Chih-Hung Hsieh <chh@google.com> | 2018-02-28 17:48:55 +0000 |
---|---|---|
committer | Chih-Hung Hsieh <chh@google.com> | 2018-02-28 17:48:55 +0000 |
commit | 9f9e4681ace64e6200f82d9d7f011701fd4e9cc8 (patch) | |
tree | 85cd726554c7030c6168567b5af93507d6996032 /llvm/lib/Target/TargetMachine.cpp | |
parent | 29abfe4a8fe08bdd2f1c3b9e139a4547eb9261cc (diff) | |
download | bcm5719-llvm-9f9e4681ace64e6200f82d9d7f011701fd4e9cc8.tar.gz bcm5719-llvm-9f9e4681ace64e6200f82d9d7f011701fd4e9cc8.zip |
[TLS] use emulated TLS if the target supports only this mode
Emulated TLS is enabled by llc flag -emulated-tls,
which is passed by clang driver.
When llc is called explicitly or from other drivers like LTO,
missing -emulated-tls flag would generate wrong TLS code for targets
that supports only this mode.
Now use useEmulatedTLS() instead of Options.EmulatedTLS to decide whether
emulated TLS code should be generated.
Unit tests are modified to run with and without the -emulated-tls flag.
Differential Revision: https://reviews.llvm.org/D42999
llvm-svn: 326341
Diffstat (limited to 'llvm/lib/Target/TargetMachine.cpp')
-rw-r--r-- | llvm/lib/Target/TargetMachine.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp index 826766890dd..2a0968565f2 100644 --- a/llvm/lib/Target/TargetMachine.cpp +++ b/llvm/lib/Target/TargetMachine.cpp @@ -192,6 +192,14 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M, return false; } +bool TargetMachine::useEmulatedTLS() const { + // Returns Options.EmulatedTLS if the -emulated-tls or -no-emulated-tls + // was specified explicitly; otherwise uses target triple to decide default. + if (Options.ExplicitEmulatedTLS) + return Options.EmulatedTLS; + return getTargetTriple().hasDefaultEmulatedTLS(); +} + TLSModel::Model TargetMachine::getTLSModel(const GlobalValue *GV) const { bool IsPIE = GV->getParent()->getPIELevel() != PIELevel::Default; Reloc::Model RM = getRelocationModel(); |