Implement target independent TLS compatible with glibc's emutls.c.
authorChih-Hung Hsieh <chh@google.com>
Tue, 28 Jul 2015 16:24:05 +0000 (16:24 +0000)
committerChih-Hung Hsieh <chh@google.com>
Tue, 28 Jul 2015 16:24:05 +0000 (16:24 +0000)
commitdc73dc09f135cb1d36fd18f1918395ddf68cec63
treee6abca46a25d7295110dd6ea0590fe8c49325210
parent751664fd1bde84a552bf91d7487ebb85ce648139
Implement target independent TLS compatible with glibc's emutls.c.

The 'common' section TLS is not implemented.
Current C/C++ TLS variables are not placed in common section.
DWARF debug info to get the address of TLS variables is not generated yet.

clang and driver changes in http://reviews.llvm.org/D10524

  Added -femulated-tls flag to select the emulated TLS model,
  which will be used for old targets like Android that do not
  support ELF TLS models.

Added TargetLowering::LowerToTLSEmulatedModel as a target-independent
function to convert a SDNode of TLS variable address to a function call
to __emutls_get_address.

Added into lib/Target/*/*ISelLowering.cpp to call LowerToTLSEmulatedModel
for TLSModel::Emulated. Although all targets supporting ELF TLS models are
enhanced, emulated TLS model has been tested only for Android ELF targets.
Modified AsmPrinter.cpp to print the emutls_v.* and emutls_t.* variables for
emulated TLS variables.
Modified DwarfCompileUnit.cpp to skip some DIE for emulated TLS variabls.

TODO: Add proper DIE for emulated TLS variables.
      Added new unit tests with emulated TLS.

Differential Revision: http://reviews.llvm.org/D10522

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243438 91177308-0d34-0410-b5e6-96231b3b80d8
32 files changed:
docs/LangRef.rst
include/llvm/CodeGen/AsmPrinter.h
include/llvm/CodeGen/CommandFlags.h
include/llvm/MC/MCObjectFileInfo.h
include/llvm/Target/TargetLowering.h
include/llvm/Target/TargetOptions.h
lib/CodeGen/AsmPrinter/AsmPrinter.cpp
lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
lib/CodeGen/SelectionDAG/TargetLowering.cpp
lib/Target/AArch64/AArch64ISelLowering.cpp
lib/Target/ARM/ARMISelLowering.cpp
lib/Target/Mips/MipsISelLowering.cpp
lib/Target/PowerPC/PPCISelLowering.cpp
lib/Target/Sparc/SparcISelLowering.cpp
lib/Target/SystemZ/SystemZISelLowering.cpp
lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/AArch64/arm64-tls-dynamic-together.ll
test/CodeGen/AArch64/emutls.ll [new file with mode: 0644]
test/CodeGen/ARM/emutls1.ll [new file with mode: 0644]
test/CodeGen/ARM/tls-models.ll
test/CodeGen/ARM/tls3.ll
test/CodeGen/Generic/emutls.ll [new file with mode: 0644]
test/CodeGen/X86/emutls-pic.ll [new file with mode: 0644]
test/CodeGen/X86/emutls-pie.ll [new file with mode: 0644]
test/CodeGen/X86/emutls.ll [new file with mode: 0644]
test/CodeGen/X86/fast-isel-emutls.ll [new file with mode: 0644]
test/CodeGen/X86/tls-android-negative.ll [new file with mode: 0644]
test/CodeGen/X86/tls-android.ll [new file with mode: 0644]
test/CodeGen/X86/tls-models.ll
test/DebugInfo/ARM/tls.ll
test/DebugInfo/X86/tls.ll
test/Transforms/GlobalOpt/tls.ll