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 | 19a4b843cc81c15c3acaf44fe42e74d1add7a634 (patch) | |
tree | 82a992c0756bc388af8578a9b2a0100bc82de833 /llvm/lib/CodeGen | |
parent | 492d4f409a05a3a2103d57f02fb4b82c749e7db3 (diff) | |
download | bcm5719-llvm-19a4b843cc81c15c3acaf44fe42e74d1add7a634.tar.gz bcm5719-llvm-19a4b843cc81c15c3acaf44fe42e74d1add7a634.zip |
Add support for initialized global data for darwin tls. Update comments
and testcases accordingly.
llvm-svn: 104635
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 21 | ||||
-rw-r--r-- | llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 5 |
2 files changed, 19 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index d0b48b0db8d..8a5fe4d3716 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/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. diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 605e2a817b1..71ad3fb6f99 100644 --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -670,11 +670,10 @@ const MCSection *TargetLoweringObjectFileMachO:: SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang, const TargetMachine &TM) const { - // Handle one kind of thread local... + // Handle thread local data. if (Kind.isThreadBSS()) return TLSBSSSection; + if (Kind.isThreadData()) return TLSDataSection; - assert(!Kind.isThreadLocal() && "Darwin doesn't support TLS"); - if (Kind.isText()) return GV->isWeakForLinker() ? TextCoalSection : TextSection; |