Weak things initialized to 0 don't go in bss on Darwin.
Cosmetic changes to spacing to match gcc (some dejagnu tests actually care). llvm-svn: 45848
This commit is contained in:
parent
b1dec454bb
commit
2ff66f08f2
|
@ -767,7 +767,7 @@ std::string DarwinAsmPrinter::getSectionForFunction(const Function &F) const {
|
||||||
case Function::InternalLinkage: return TAI->getTextSection();
|
case Function::InternalLinkage: return TAI->getTextSection();
|
||||||
case Function::WeakLinkage:
|
case Function::WeakLinkage:
|
||||||
case Function::LinkOnceLinkage:
|
case Function::LinkOnceLinkage:
|
||||||
return ".section __TEXT,__textcoal_nt,coalesced,pure_instructions";
|
return "\t.section __TEXT,__textcoal_nt,coalesced,pure_instructions";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -869,13 +869,13 @@ bool DarwinAsmPrinter::doInitialization(Module &M) {
|
||||||
|
|
||||||
// Prime text sections so they are adjacent. This reduces the likelihood a
|
// Prime text sections so they are adjacent. This reduces the likelihood a
|
||||||
// large data or debug section causes a branch to exceed 16M limit.
|
// large data or debug section causes a branch to exceed 16M limit.
|
||||||
SwitchToTextSection(".section __TEXT,__textcoal_nt,coalesced,"
|
SwitchToTextSection("\t.section __TEXT,__textcoal_nt,coalesced,"
|
||||||
"pure_instructions");
|
"pure_instructions");
|
||||||
if (TM.getRelocationModel() == Reloc::PIC_) {
|
if (TM.getRelocationModel() == Reloc::PIC_) {
|
||||||
SwitchToTextSection(".section __TEXT,__picsymbolstub1,symbol_stubs,"
|
SwitchToTextSection("\t.section __TEXT,__picsymbolstub1,symbol_stubs,"
|
||||||
"pure_instructions,32");
|
"pure_instructions,32");
|
||||||
} else if (TM.getRelocationModel() == Reloc::DynamicNoPIC) {
|
} else if (TM.getRelocationModel() == Reloc::DynamicNoPIC) {
|
||||||
SwitchToTextSection(".section __TEXT,__symbol_stub1,symbol_stubs,"
|
SwitchToTextSection("\t.section __TEXT,__symbol_stub1,symbol_stubs,"
|
||||||
"pure_instructions,16");
|
"pure_instructions,16");
|
||||||
}
|
}
|
||||||
SwitchToTextSection(TAI->getTextSection());
|
SwitchToTextSection(TAI->getTextSection());
|
||||||
|
@ -917,8 +917,7 @@ bool DarwinAsmPrinter::doFinalization(Module &M) {
|
||||||
|
|
||||||
if (C->isNullValue() && /* FIXME: Verify correct */
|
if (C->isNullValue() && /* FIXME: Verify correct */
|
||||||
!I->hasSection() &&
|
!I->hasSection() &&
|
||||||
(I->hasInternalLinkage() || I->hasWeakLinkage() ||
|
(I->hasInternalLinkage() || I->hasExternalLinkage())) {
|
||||||
I->hasLinkOnceLinkage() || I->hasExternalLinkage())) {
|
|
||||||
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
|
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
|
||||||
if (I->hasExternalLinkage()) {
|
if (I->hasExternalLinkage()) {
|
||||||
O << "\t.globl " << name << '\n';
|
O << "\t.globl " << name << '\n';
|
||||||
|
@ -941,7 +940,7 @@ bool DarwinAsmPrinter::doFinalization(Module &M) {
|
||||||
case GlobalValue::WeakLinkage:
|
case GlobalValue::WeakLinkage:
|
||||||
O << "\t.globl " << name << '\n'
|
O << "\t.globl " << name << '\n'
|
||||||
<< "\t.weak_definition " << name << '\n';
|
<< "\t.weak_definition " << name << '\n';
|
||||||
SwitchToDataSection(".section __DATA,__datacoal_nt,coalesced", I);
|
SwitchToDataSection("\t.section __DATA,__datacoal_nt,coalesced", I);
|
||||||
break;
|
break;
|
||||||
case GlobalValue::AppendingLinkage:
|
case GlobalValue::AppendingLinkage:
|
||||||
// FIXME: appending linkage variables should go into a section of
|
// FIXME: appending linkage variables should go into a section of
|
||||||
|
@ -1008,7 +1007,7 @@ bool DarwinAsmPrinter::doFinalization(Module &M) {
|
||||||
if (TM.getRelocationModel() == Reloc::PIC_) {
|
if (TM.getRelocationModel() == Reloc::PIC_) {
|
||||||
for (std::set<std::string>::iterator i = FnStubs.begin(), e = FnStubs.end();
|
for (std::set<std::string>::iterator i = FnStubs.begin(), e = FnStubs.end();
|
||||||
i != e; ++i) {
|
i != e; ++i) {
|
||||||
SwitchToTextSection(".section __TEXT,__picsymbolstub1,symbol_stubs,"
|
SwitchToTextSection("\t.section __TEXT,__picsymbolstub1,symbol_stubs,"
|
||||||
"pure_instructions,32");
|
"pure_instructions,32");
|
||||||
EmitAlignment(4);
|
EmitAlignment(4);
|
||||||
O << "L" << *i << "$stub:\n";
|
O << "L" << *i << "$stub:\n";
|
||||||
|
@ -1036,7 +1035,7 @@ bool DarwinAsmPrinter::doFinalization(Module &M) {
|
||||||
} else {
|
} else {
|
||||||
for (std::set<std::string>::iterator i = FnStubs.begin(), e = FnStubs.end();
|
for (std::set<std::string>::iterator i = FnStubs.begin(), e = FnStubs.end();
|
||||||
i != e; ++i) {
|
i != e; ++i) {
|
||||||
SwitchToTextSection(".section __TEXT,__symbol_stub1,symbol_stubs,"
|
SwitchToTextSection("\t.section __TEXT,__symbol_stub1,symbol_stubs,"
|
||||||
"pure_instructions,16");
|
"pure_instructions,16");
|
||||||
EmitAlignment(4);
|
EmitAlignment(4);
|
||||||
O << "L" << *i << "$stub:\n";
|
O << "L" << *i << "$stub:\n";
|
||||||
|
|
|
@ -53,7 +53,7 @@ DarwinTargetAsmInfo::DarwinTargetAsmInfo(const PPCTargetMachine &TM)
|
||||||
UsedDirective = "\t.no_dead_strip\t";
|
UsedDirective = "\t.no_dead_strip\t";
|
||||||
WeakDefDirective = "\t.weak_definition ";
|
WeakDefDirective = "\t.weak_definition ";
|
||||||
WeakRefDirective = "\t.weak_reference ";
|
WeakRefDirective = "\t.weak_reference ";
|
||||||
HiddenDirective = "\t.private_extern\t";
|
HiddenDirective = "\t.private_extern ";
|
||||||
SupportsExceptionHandling = true;
|
SupportsExceptionHandling = true;
|
||||||
NeedsIndirectEncoding = true;
|
NeedsIndirectEncoding = true;
|
||||||
NeedsSet = true;
|
NeedsSet = true;
|
||||||
|
|
|
@ -173,7 +173,7 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
|
||||||
if (C->isNullValue() && !I->hasSection()) {
|
if (C->isNullValue() && !I->hasSection()) {
|
||||||
if (I->hasExternalLinkage()) {
|
if (I->hasExternalLinkage()) {
|
||||||
if (const char *Directive = TAI->getZeroFillDirective()) {
|
if (const char *Directive = TAI->getZeroFillDirective()) {
|
||||||
O << "\t.globl\t" << name << "\n";
|
O << "\t.globl " << name << "\n";
|
||||||
O << Directive << "__DATA__, __common, " << name << ", "
|
O << Directive << "__DATA__, __common, " << name << ", "
|
||||||
<< Size << ", " << Align << "\n";
|
<< Size << ", " << Align << "\n";
|
||||||
continue;
|
continue;
|
||||||
|
@ -181,8 +181,9 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!I->isThreadLocal() &&
|
if (!I->isThreadLocal() &&
|
||||||
(I->hasInternalLinkage() || I->hasWeakLinkage() ||
|
(I->hasInternalLinkage() ||
|
||||||
I->hasLinkOnceLinkage())) {
|
(!Subtarget->isTargetDarwin() &&
|
||||||
|
(I->hasWeakLinkage() || I->hasLinkOnceLinkage())))) {
|
||||||
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
|
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
|
||||||
if (!NoZerosInBSS && TAI->getBSSSection())
|
if (!NoZerosInBSS && TAI->getBSSSection())
|
||||||
SwitchToDataSection(TAI->getBSSSection(), I);
|
SwitchToDataSection(TAI->getBSSSection(), I);
|
||||||
|
@ -218,9 +219,9 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
|
||||||
case GlobalValue::LinkOnceLinkage:
|
case GlobalValue::LinkOnceLinkage:
|
||||||
case GlobalValue::WeakLinkage:
|
case GlobalValue::WeakLinkage:
|
||||||
if (Subtarget->isTargetDarwin()) {
|
if (Subtarget->isTargetDarwin()) {
|
||||||
O << "\t.globl\t" << name << "\n"
|
O << "\t.globl " << name << "\n"
|
||||||
<< TAI->getWeakDefDirective() << name << "\n";
|
<< TAI->getWeakDefDirective() << name << "\n";
|
||||||
SwitchToDataSection(".section __DATA,__const_coal,coalesced", I);
|
SwitchToDataSection("\t.section __DATA,__datacoal_nt,coalesced", I);
|
||||||
} else if (Subtarget->isTargetCygMing()) {
|
} else if (Subtarget->isTargetCygMing()) {
|
||||||
std::string SectionName(".section\t.data$linkonce." +
|
std::string SectionName(".section\t.data$linkonce." +
|
||||||
name +
|
name +
|
||||||
|
@ -244,7 +245,7 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
|
||||||
// their name or something. For now, just emit them as external.
|
// 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
|
// If external or appending, declare as a global symbol
|
||||||
O << "\t.globl\t" << name << "\n";
|
O << "\t.globl " << name << "\n";
|
||||||
// FALL THROUGH
|
// FALL THROUGH
|
||||||
case GlobalValue::InternalLinkage: {
|
case GlobalValue::InternalLinkage: {
|
||||||
if (I->isConstant()) {
|
if (I->isConstant()) {
|
||||||
|
@ -348,7 +349,7 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
|
||||||
unsigned j = 1;
|
unsigned j = 1;
|
||||||
for (std::set<std::string>::iterator i = FnStubs.begin(), e = FnStubs.end();
|
for (std::set<std::string>::iterator i = FnStubs.begin(), e = FnStubs.end();
|
||||||
i != e; ++i, ++j) {
|
i != e; ++i, ++j) {
|
||||||
SwitchToDataSection(".section __IMPORT,__jump_table,symbol_stubs,"
|
SwitchToDataSection("\t.section __IMPORT,__jump_table,symbol_stubs,"
|
||||||
"self_modifying_code+pure_instructions,5", 0);
|
"self_modifying_code+pure_instructions,5", 0);
|
||||||
O << "L" << *i << "$stub:\n";
|
O << "L" << *i << "$stub:\n";
|
||||||
O << "\t.indirect_symbol " << *i << "\n";
|
O << "\t.indirect_symbol " << *i << "\n";
|
||||||
|
@ -369,7 +370,7 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
|
||||||
// Output stubs for external and common global variables.
|
// Output stubs for external and common global variables.
|
||||||
if (!GVStubs.empty())
|
if (!GVStubs.empty())
|
||||||
SwitchToDataSection(
|
SwitchToDataSection(
|
||||||
".section __IMPORT,__pointers,non_lazy_symbol_pointers");
|
"\t.section __IMPORT,__pointers,non_lazy_symbol_pointers");
|
||||||
for (std::set<std::string>::iterator i = GVStubs.begin(), e = GVStubs.end();
|
for (std::set<std::string>::iterator i = GVStubs.begin(), e = GVStubs.end();
|
||||||
i != e; ++i) {
|
i != e; ++i) {
|
||||||
O << "L" << *i << "$non_lazy_ptr:\n";
|
O << "L" << *i << "$non_lazy_ptr:\n";
|
||||||
|
|
|
@ -78,7 +78,7 @@ X86TargetAsmInfo::X86TargetAsmInfo(const X86TargetMachine &TM) {
|
||||||
UsedDirective = "\t.no_dead_strip\t";
|
UsedDirective = "\t.no_dead_strip\t";
|
||||||
WeakDefDirective = "\t.weak_definition ";
|
WeakDefDirective = "\t.weak_definition ";
|
||||||
WeakRefDirective = "\t.weak_reference ";
|
WeakRefDirective = "\t.weak_reference ";
|
||||||
HiddenDirective = "\t.private_extern\t";
|
HiddenDirective = "\t.private_extern ";
|
||||||
|
|
||||||
// In non-PIC modes, emit a special label before jump tables so that the
|
// In non-PIC modes, emit a special label before jump tables so that the
|
||||||
// linker can perform more accurate dead code stripping.
|
// linker can perform more accurate dead code stripping.
|
||||||
|
|
Loading…
Reference in New Issue