diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2012-04-08 17:20:55 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2012-04-08 17:20:55 +0000 |
commit | 16f0ebcbb576f197422426b64f4ad54269f273d1 (patch) | |
tree | f94dbbb626c8a538a889f870637d375f1da36cf3 /llvm/lib/Target/TargetMachine.cpp | |
parent | c0c0455f5596906ca01d344dc8a4e4d0f35c72b9 (diff) | |
download | llvm-16f0ebcbb576f197422426b64f4ad54269f273d1.zip llvm-16f0ebcbb576f197422426b64f4ad54269f273d1.tar.gz llvm-16f0ebcbb576f197422426b64f4ad54269f273d1.tar.bz2 |
Move the TLSModel information into the TargetMachine rather than hiding
in TargetLowering. There was already a FIXME about this location being
odd. The interface is simplified as a consequence. This will also make
it easier to change TLS models when compiling with PIE.
llvm-svn: 154292
Diffstat (limited to 'llvm/lib/Target/TargetMachine.cpp')
-rw-r--r-- | llvm/lib/Target/TargetMachine.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp index 6eae385..b8e7f15 100644 --- a/llvm/lib/Target/TargetMachine.cpp +++ b/llvm/lib/Target/TargetMachine.cpp @@ -11,6 +11,7 @@ // //===----------------------------------------------------------------------===// +#include "llvm/GlobalValue.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCCodeGenInfo.h" #include "llvm/Target/TargetMachine.h" @@ -74,6 +75,26 @@ CodeModel::Model TargetMachine::getCodeModel() const { return CodeGenInfo->getCodeModel(); } +TLSModel::Model TargetMachine::getTLSModel(const GlobalValue *GV) const { + bool isLocal = GV->hasLocalLinkage(); + bool isDeclaration = GV->isDeclaration(); + // FIXME: what should we do for protected and internal visibility? + // For variables, is internal different from hidden? + bool isHidden = GV->hasHiddenVisibility(); + + if (getRelocationModel() == Reloc::PIC_) { + if (isLocal || isHidden) + return TLSModel::LocalDynamic; + else + return TLSModel::GeneralDynamic; + } else { + if (!isDeclaration || isHidden) + return TLSModel::LocalExec; + else + return TLSModel::InitialExec; + } +} + /// getOptLevel - Returns the optimization level: None, Less, /// Default, or Aggressive. CodeGenOpt::Level TargetMachine::getOptLevel() const { |