aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/Target/TargetLoweringObjectFile.h6
-rw-r--r--lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp26
-rw-r--r--lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp55
-rw-r--r--lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp26
4 files changed, 41 insertions, 72 deletions
diff --git a/include/llvm/Target/TargetLoweringObjectFile.h b/include/llvm/Target/TargetLoweringObjectFile.h
index b8da445ceb..304518abe7 100644
--- a/include/llvm/Target/TargetLoweringObjectFile.h
+++ b/include/llvm/Target/TargetLoweringObjectFile.h
@@ -313,12 +313,6 @@ public:
return ConstTextCoalSection;
}
- /// getDataCommonSection - Return the "__DATA,__common" section we put
- /// zerofill (aka bss) data into.
- bool isDataCommonSection(const MCSection *Section) const {
- return Section == DataCommonSection;
- }
-
/// getLazySymbolPointerSection - Return the section corresponding to
/// the .lazy_symbol_pointer directive.
const MCSection *getLazySymbolPointerSection() const {
diff --git a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
index 738f257833..fd26169db3 100644
--- a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
+++ b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
@@ -1220,25 +1220,15 @@ void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
// Handle the zerofill directive on darwin, which is a special form of BSS
// emission.
- if (GVKind.isBSS() && MAI->hasMachoZeroFillDirective()) {
- TargetLoweringObjectFileMachO &TLOFMacho =
- static_cast<TargetLoweringObjectFileMachO &>(getObjFileLowering());
- if (TLOFMacho.isDataCommonSection(TheSection)) {
- // .globl _foo
- OutStreamer.EmitSymbolAttribute(GVarSym, MCStreamer::Global);
- // .zerofill __DATA, __common, _foo, 400, 5
- OutStreamer.EmitZerofill(TheSection, GVarSym, Size, 1 << Align);
- return;
- }
+ if (GVKind.isBSSExtern() && MAI->hasMachoZeroFillDirective()) {
+ // .globl _foo
+ OutStreamer.EmitSymbolAttribute(GVarSym, MCStreamer::Global);
+ // .zerofill __DATA, __common, _foo, 400, 5
+ OutStreamer.EmitZerofill(TheSection, GVarSym, Size, 1 << Align);
+ return;
}
- OutStreamer.SwitchSection(TheSection);
-
- // FIXME: get this stuff from section kind flags.
- if (C->isNullValue() && !GVar->hasSection() && !GVar->isThreadLocal() &&
- // Don't put things that should go in the cstring section into "comm".
- !TheSection->getKind().isMergeableCString() &&
- (GVar->hasLocalLinkage() || GVar->hasLocalLinkage())) {
+ if (GVKind.isBSSLocal()) {
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
if (isDarwin) {
@@ -1262,6 +1252,8 @@ void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
return;
}
+ OutStreamer.SwitchSection(TheSection);
+
switch (GVar->getLinkage()) {
case GlobalValue::CommonLinkage:
case GlobalValue::LinkOnceAnyLinkage:
diff --git a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
index 4b69f0bb7c..e17d89a363 100644
--- a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
+++ b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
@@ -733,10 +733,7 @@ void PPCLinuxAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
return;
}
- OutStreamer.SwitchSection(getObjFileLowering().
- SectionForGlobal(GVar, GVKind, Mang, TM));
-
- if (C->isNullValue() && !GVar->hasSection() && GVar->hasLocalLinkage()) {
+ if (GVKind.isBSSLocal()) {
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
O << MAI->getLCOMMDirective() << *GVarSym << ',' << Size;
@@ -750,28 +747,30 @@ void PPCLinuxAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
return;
}
+ OutStreamer.SwitchSection(getObjFileLowering().
+ SectionForGlobal(GVar, GVKind, Mang, TM));
+
switch (GVar->getLinkage()) {
- case GlobalValue::LinkOnceAnyLinkage:
- case GlobalValue::LinkOnceODRLinkage:
- case GlobalValue::WeakAnyLinkage:
- case GlobalValue::WeakODRLinkage:
- case GlobalValue::CommonLinkage:
- case GlobalValue::LinkerPrivateLinkage:
+ case GlobalValue::LinkOnceAnyLinkage:
+ case GlobalValue::LinkOnceODRLinkage:
+ case GlobalValue::WeakAnyLinkage:
+ case GlobalValue::WeakODRLinkage:
+ case GlobalValue::LinkerPrivateLinkage:
O << "\t.global " << *GVarSym;
O << "\n\t.type " << *GVarSym << ", @object\n\t.weak " << *GVarSym << '\n';
break;
- case GlobalValue::AppendingLinkage:
+ case GlobalValue::AppendingLinkage:
// FIXME: appending linkage variables should go into a section of
// their name or something. For now, just emit them as external.
- case GlobalValue::ExternalLinkage:
+ case GlobalValue::ExternalLinkage:
// If external or appending, declare as a global symbol
O << "\t.global " << *GVarSym;
O << "\n\t.type " << *GVarSym << ", @object\n";
// FALL THROUGH
- case GlobalValue::InternalLinkage:
- case GlobalValue::PrivateLinkage:
+ case GlobalValue::InternalLinkage:
+ case GlobalValue::PrivateLinkage:
break;
- default:
+ default:
llvm_unreachable("Unknown linkage type!");
}
@@ -976,25 +975,15 @@ void PPCDarwinAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
// Handle the zerofill directive on darwin, which is a special form of BSS
// emission.
- if (GVKind.isBSS() && MAI->hasMachoZeroFillDirective()) {
- TargetLoweringObjectFileMachO &TLOFMacho =
- static_cast<TargetLoweringObjectFileMachO &>(getObjFileLowering());
- if (TLOFMacho.isDataCommonSection(TheSection)) {
- // .globl _foo
- OutStreamer.EmitSymbolAttribute(GVarSym, MCStreamer::Global);
- // .zerofill __DATA, __common, _foo, 400, 5
- OutStreamer.EmitZerofill(TheSection, GVarSym, Size, 1 << Align);
- return;
- }
+ if (GVKind.isBSSExtern() && MAI->hasMachoZeroFillDirective()) {
+ // .globl _foo
+ OutStreamer.EmitSymbolAttribute(GVarSym, MCStreamer::Global);
+ // .zerofill __DATA, __common, _foo, 400, 5
+ OutStreamer.EmitZerofill(TheSection, GVarSym, Size, 1 << Align);
+ return;
}
- OutStreamer.SwitchSection(TheSection);
-
- /// FIXME: Drive this off the section!
- if (C->isNullValue() && /* FIXME: Verify correct */
- !GVar->hasSection() && GVar->hasLocalLinkage() &&
- // Don't put things that should go in the cstring section into "comm".
- !TheSection->getKind().isMergeableCString()) {
+ if (GVKind.isBSSLocal()) {
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
O << MAI->getLCOMMDirective() << *GVarSym << ',' << Size << ',' << Align;
@@ -1008,6 +997,8 @@ void PPCDarwinAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
return;
}
+ OutStreamer.SwitchSection(TheSection);
+
switch (GVar->getLinkage()) {
case GlobalValue::LinkOnceAnyLinkage:
case GlobalValue::LinkOnceODRLinkage:
diff --git a/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
index f32a659f72..438c208ad8 100644
--- a/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
+++ b/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
@@ -699,25 +699,15 @@ void X86AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
// Handle the zerofill directive on darwin, which is a special form of BSS
// emission.
- if (GVKind.isBSS() && MAI->hasMachoZeroFillDirective()) {
- TargetLoweringObjectFileMachO &TLOFMacho =
- static_cast<TargetLoweringObjectFileMachO &>(getObjFileLowering());
- if (TLOFMacho.isDataCommonSection(TheSection)) {
- // .globl _foo
- OutStreamer.EmitSymbolAttribute(GVarSym, MCStreamer::Global);
- // .zerofill __DATA, __common, _foo, 400, 5
- OutStreamer.EmitZerofill(TheSection, GVarSym, Size, 1 << Align);
- return;
- }
+ if (GVKind.isBSSExtern() && MAI->hasMachoZeroFillDirective()) {
+ // .globl _foo
+ OutStreamer.EmitSymbolAttribute(GVarSym, MCStreamer::Global);
+ // .zerofill __DATA, __common, _foo, 400, 5
+ OutStreamer.EmitZerofill(TheSection, GVarSym, Size, 1 << Align);
+ return;
}
- OutStreamer.SwitchSection(TheSection);
-
- // FIXME: get this stuff from section kind flags.
- if (C->isNullValue() && !GVar->hasSection() &&
- // Don't put things that should go in the cstring section into "comm".
- !TheSection->getKind().isMergeableCString() &&
- !GVar->isThreadLocal() && GVar->hasLocalLinkage()) {
+ if (GVKind.isBSSLocal()) {
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
if (const char *LComm = MAI->getLCOMMDirective()) {
@@ -742,6 +732,8 @@ void X86AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
return;
}
+ OutStreamer.SwitchSection(TheSection);
+
switch (GVar->getLinkage()) {
case GlobalValue::CommonLinkage:
case GlobalValue::LinkOnceAnyLinkage: