/// doInitialization
bool X86SharedAsmPrinter::doInitialization(Module &M) {
- if (Subtarget->isTargetELF() ||
- Subtarget->isTargetCygMing() ||
- Subtarget->isTargetDarwin()) {
+ if (TAI->doesSupportDebugInformation()) {
// Emit initial debug information.
DW.BeginModule(&M);
}
- return AsmPrinter::doInitialization(M);
+ bool Result = AsmPrinter::doInitialization(M);
+
+ // Darwin wants symbols to be quoted if they have complex names.
+ if (Subtarget->isTargetDarwin())
+ Mang->setUseQuotes(true);
+
+ return Result;
}
bool X86SharedAsmPrinter::doFinalization(Module &M) {
}
if (Subtarget->isTargetELF())
- O << "\t.type " << name << ",@object\n";
+ O << "\t.type\t" << name << ",@object\n";
- if (C->isNullValue()) {
+ if (C->isNullValue() && !I->hasSection()) {
if (I->hasExternalLinkage()) {
if (const char *Directive = TAI->getZeroFillDirective()) {
O << "\t.globl\t" << name << "\n";
}
}
- if (!I->hasSection() && !I->isThreadLocal() &&
+ if (!I->isThreadLocal() &&
(I->hasInternalLinkage() || I->hasWeakLinkage() ||
I->hasLinkOnceLinkage())) {
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
case GlobalValue::LinkOnceLinkage:
case GlobalValue::WeakLinkage:
if (Subtarget->isTargetDarwin()) {
- O << "\t.globl " << name << "\n"
+ O << "\t.globl\t" << name << "\n"
<< "\t.weak_definition " << name << "\n";
SwitchToDataSection(".section __DATA,__const_coal,coalesced", I);
} else if (Subtarget->isTargetCygMing()) {
name +
",\"aw\"");
SwitchToDataSection(SectionName.c_str(), I);
- O << "\t.globl " << name << "\n"
+ O << "\t.globl\t" << name << "\n"
<< "\t.linkonce same_size\n";
} else {
std::string SectionName("\t.section\t.llvm.linkonce.d." +
name +
",\"aw\",@progbits");
SwitchToDataSection(SectionName.c_str(), I);
- O << "\t.weak " << name << "\n";
+ O << "\t.weak\t" << name << "\n";
}
break;
- 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::DLLExportLinkage:
DLLExportedGVs.insert(Mang->makeNameProper(I->getName(),""));
// FALL THROUGH
+ 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:
// If external or appending, declare as a global symbol
- O << "\t.globl " << name << "\n";
+ O << "\t.globl\t" << name << "\n";
// FALL THROUGH
case GlobalValue::InternalLinkage: {
if (I->isConstant()) {
O << name << ":\t\t\t\t" << TAI->getCommentString() << " " << I->getName()
<< "\n";
if (TAI->hasDotTypeDotSizeDirective())
- O << "\t.size " << name << ", " << Size << "\n";
+ O << "\t.size\t" << name << ", " << Size << "\n";
// If the initializer is a extern weak symbol, remember to emit the weak
// reference!
if (const GlobalValue *GV = dyn_cast<GlobalValue>(C))
ExtWeakSymbols.insert(GV);
EmitGlobalConstant(C);
- O << '\n';
}
// Output linker support code for dllexported globals
- if (DLLExportedGVs.begin() != DLLExportedGVs.end()) {
+ if (!DLLExportedGVs.empty()) {
SwitchToDataSection(".section .drectve");
}
O << "\t.ascii \" -export:" << *i << ",data\"\n";
}
- if (DLLExportedFns.begin() != DLLExportedFns.end()) {
+ if (!DLLExportedFns.empty()) {
SwitchToDataSection(".section .drectve");
}
O << "\n";
+ if (ExceptionHandling && TAI->doesSupportExceptionHandling() && MMI) {
+ // Add the (possibly multiple) personalities to the set of global values.
+ const std::vector<Function *>& Personalities = MMI->getPersonalities();
+
+ for (std::vector<Function *>::const_iterator I = Personalities.begin(),
+ E = Personalities.end(); I != E; ++I)
+ if (*I) GVStubs.insert("_" + (*I)->getName());
+ }
+
// Output stubs for external and common global variables.
- if (GVStubs.begin() != GVStubs.end())
+ if (!GVStubs.empty())
SwitchToDataSection(
".section __IMPORT,__pointers,non_lazy_symbol_pointers");
for (std::set<std::string>::iterator i = GVStubs.begin(), e = GVStubs.end();
DW.EndModule();
}
- AsmPrinter::doFinalization(M);
- return false; // success
+ return AsmPrinter::doFinalization(M);
}
/// createX86CodePrinterPass - Returns a pass that prints the X86 assembly code