diff options
author | Eric Christopher <echristo@apple.com> | 2010-05-25 21:28:50 +0000 |
---|---|---|
committer | Eric Christopher <echristo@apple.com> | 2010-05-25 21:28:50 +0000 |
commit | 02b46bc9426925b90137d264216a54aa413335fd (patch) | |
tree | e4a7a2083bea582e3351b89a9bbb7db1b9a1a5a5 /lib/CodeGen/AsmPrinter/AsmPrinter.cpp | |
parent | cf50a5390c09325a7fc41640449205eced4363f6 (diff) |
Add support for initialized global data for darwin tls. Update comments
and testcases accordingly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104635 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/AsmPrinter/AsmPrinter.cpp')
-rw-r--r-- | lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index d0b48b0db8..8a5fe4d371 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -311,13 +311,26 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) { return; } - // Handle the tbss directive on darwin which is a thread local bss directive - // like zerofill. - if (GVKind.isThreadBSS() && MAI->hasMachoTBSSDirective()) { + // Handle thread local data for mach-o which requires us to output an + // additional structure of data and mangle the original symbol so that we + // can reference it later. + if (GVKind.isThreadLocal() && MAI->hasMachoTBSSDirective()) { // Emit the .tbss symbol MCSymbol *MangSym = OutContext.GetOrCreateSymbol(GVSym->getName() + Twine("$tlv$init")); - OutStreamer.EmitTBSSSymbol(TheSection, MangSym, Size, 1 << AlignLog); + + if (GVKind.isThreadBSS()) + OutStreamer.EmitTBSSSymbol(TheSection, MangSym, Size, 1 << AlignLog); + else if (GVKind.isThreadData()) { + OutStreamer.SwitchSection(TheSection); + + EmitLinkage(GV->getLinkage(), MangSym); + EmitAlignment(AlignLog, GV); + OutStreamer.EmitLabel(MangSym); + + EmitGlobalConstant(GV->getInitializer()); + } + OutStreamer.AddBlankLine(); // Emit the variable struct for the runtime. |