[llvm-commits] [llvm] r104414 - in /llvm/trunk: lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/CodeGen/TargetLoweringObjectFileImpl.cpp test/CodeGen/X86/tls-1.ll
Eric Christopher
echristo at apple.com
Fri May 21 17:10:22 PDT 2010
Author: echristo
Date: Fri May 21 19:10:22 2010
New Revision: 104414
URL: http://llvm.org/viewvc/llvm-project?rev=104414&view=rev
Log:
Add full bss data support for darwin tls variables.
Added:
llvm/trunk/test/CodeGen/X86/tls-1.ll
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=104414&r1=104413&r2=104414&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Fri May 21 19:10:22 2010
@@ -314,7 +314,32 @@
// Handle the tbss directive on darwin which is a thread local bss directive
// like zerofill.
if (GVKind.isThreadBSS() && MAI->hasMachoTBSSDirective()) {
- OutStreamer.EmitTBSSSymbol(TheSection, GVSym, Size, 1 << AlignLog);
+ // Emit the .tbss symbol
+ MCSymbol *MangSym =
+ OutContext.GetOrCreateSymbol(GVSym->getName() + Twine("$tlv$init"));
+ OutStreamer.EmitTBSSSymbol(TheSection, MangSym, Size, 1 << AlignLog);
+ OutStreamer.AddBlankLine();
+
+ // Emit the variable struct for the runtime.
+ const MCSection *TLVSect
+ = getObjFileLowering().getTLSExtraDataSection();
+
+ OutStreamer.SwitchSection(TLVSect);
+ // Emit the linkage here.
+ EmitLinkage(GV->getLinkage(), GVSym);
+ OutStreamer.EmitLabel(GVSym);
+
+ // Three pointers in size:
+ // - __tlv_bootstrap - used to make sure support exists
+ // - spare pointer, used when mapped by the runtime
+ // - pointer to mangled symbol above with initializer
+ unsigned PtrSize = TD->getPointerSizeInBits()/8;
+ OutStreamer.EmitSymbolValue(GetExternalSymbolSymbol("__tlv_bootstrap"),
+ PtrSize, 0);
+ OutStreamer.EmitIntValue(0, PtrSize, 0);
+ OutStreamer.EmitSymbolValue(MangSym, PtrSize, 0);
+
+ OutStreamer.AddBlankLine();
return;
}
Modified: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp?rev=104414&r1=104413&r2=104414&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (original)
+++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp Fri May 21 19:10:22 2010
@@ -627,6 +627,8 @@
getContext().getMachOSection("__DWARF", "__debug_inlined",
MCSectionMachO::S_ATTR_DEBUG,
SectionKind::getMetadata());
+
+ TLSExtraDataSection = TLSTLVSection;
}
const MCSection *TargetLoweringObjectFileMachO::
@@ -666,9 +668,13 @@
const MCSection *TargetLoweringObjectFileMachO::
SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
- Mangler *Mang, const TargetMachine &TM) const {
- assert(!Kind.isThreadLocal() && "Darwin doesn't support TLS");
+ Mangler *Mang, const TargetMachine &TM) const {
+
+ // Handle one kind of thread local...
+ if (Kind.isThreadBSS()) return TLSBSSSection;
+ assert(!Kind.isThreadLocal() && "Darwin doesn't support TLS");
+
if (Kind.isText())
return GV->isWeakForLinker() ? TextCoalSection : TextSection;
Added: llvm/trunk/test/CodeGen/X86/tls-1.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tls-1.ll?rev=104414&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/tls-1.ll (added)
+++ llvm/trunk/test/CodeGen/X86/tls-1.ll Fri May 21 19:10:22 2010
@@ -0,0 +1,19 @@
+; RUN: llc < %s -march=x86-64 | FileCheck %s
+
+ at a = thread_local global i32 0 ; <i32*> [#uses=0]
+ at b = thread_local global i32 0 ; <i32*> [#uses=0]
+
+; CHECK: .tbss _a$tlv$init, 4, 2
+; CHECK: .section __DATA,__thread_vars,thread_local_variables
+; CHECK: .globl _a
+; CHECK: _a:
+; CHECK: .quad ___tlv_bootstrap
+; CHECK: .quad 0
+; CHECK: .quad _a$tlv$init
+
+; CHECK: .tbss _b$tlv$init, 4, 2
+; CHECK: .globl _b
+; CHECK: _b:
+; CHECK: .quad ___tlv_bootstrap
+; CHECK: .quad 0
+; CHECK: .quad _b$tlv$init
More information about the llvm-commits
mailing list