From c1a887d76d95100e7e05aa76e077710bc4e0b1cf Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Thu, 20 May 2010 00:49:07 +0000 Subject: [PATCH] Partial code for emitting thread local bss data. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104197 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCAsmInfo.h | 1 + lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 7 +++++++ lib/MC/MCAsmInfo.cpp | 1 + lib/MC/MCAsmInfoDarwin.cpp | 1 + 4 files changed, 10 insertions(+) diff --git a/include/llvm/MC/MCAsmInfo.h b/include/llvm/MC/MCAsmInfo.h index f57f6426e0a..e5f82825629 100644 --- a/include/llvm/MC/MCAsmInfo.h +++ b/include/llvm/MC/MCAsmInfo.h @@ -303,6 +303,7 @@ namespace llvm { // Accessors. // bool hasMachoZeroFillDirective() const { return HasMachoZeroFillDirective; } + bool hasMachoTBSSDirective() const { return HasMachoTBSSDirective; } bool hasStaticCtorDtorReferenceInStaticMode() const { return HasStaticCtorDtorReferenceInStaticMode; } diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index bd7d0e5324a..50a50750e8b 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -310,6 +310,13 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) { OutStreamer.EmitZerofill(TheSection, GVSym, Size, 1 << AlignLog); return; } + + // 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); + return; + } OutStreamer.SwitchSection(TheSection); diff --git a/lib/MC/MCAsmInfo.cpp b/lib/MC/MCAsmInfo.cpp index 2b239946370..a275be2c53c 100644 --- a/lib/MC/MCAsmInfo.cpp +++ b/lib/MC/MCAsmInfo.cpp @@ -21,6 +21,7 @@ using namespace llvm; MCAsmInfo::MCAsmInfo() { HasSubsectionsViaSymbols = false; HasMachoZeroFillDirective = false; + HasMachoTBSSDirective = false; HasStaticCtorDtorReferenceInStaticMode = false; MaxInstLength = 4; PCSymbol = "$"; diff --git a/lib/MC/MCAsmInfoDarwin.cpp b/lib/MC/MCAsmInfoDarwin.cpp index 3c31caa5aca..0bd3b2d001e 100644 --- a/lib/MC/MCAsmInfoDarwin.cpp +++ b/lib/MC/MCAsmInfoDarwin.cpp @@ -35,6 +35,7 @@ MCAsmInfoDarwin::MCAsmInfoDarwin() { WeakRefDirective = "\t.weak_reference "; ZeroDirective = "\t.space\t"; // ".space N" emits N zeros. HasMachoZeroFillDirective = true; // Uses .zerofill + HasMachoTBSSDirective = true; // Uses .tbss HasStaticCtorDtorReferenceInStaticMode = true; HiddenVisibilityAttr = MCSA_PrivateExtern;