rearrange X86ATTAsmPrinter::doFinalization, making a scan of
the global variable list only happen for COFF targets.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82010 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
index c2c3855..4085f98 100644
--- a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
+++ b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
@@ -889,13 +889,6 @@
}
bool X86ATTAsmPrinter::doFinalization(Module &M) {
- // Print out module-level global variables here.
- for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
- I != E; ++I) {
- if (I->hasDLLExportLinkage())
- DLLExportedGVs.insert(Mang->getMangledName(I));
- }
-
if (Subtarget->isTargetDarwin()) {
// All darwin targets use mach-o.
TargetLoweringObjectFileMachO &TLOFMacho =
@@ -903,7 +896,7 @@
// Add the (possibly multiple) personalities to the set of global value
// stubs. Only referenced functions get into the Personalities list.
- if (MAI->doesSupportExceptionHandling() && MMI && !Subtarget->is64Bit()) {
+ if (!Subtarget->is64Bit()) {
const std::vector<Function*> &Personalities = MMI->getPersonalities();
for (unsigned i = 0, e = Personalities.size(); i != e; ++i) {
if (Personalities[i] == 0)
@@ -984,37 +977,46 @@
// linker can safely perform dead code stripping. Since LLVM never
// generates code that does this, it is always safe to set.
O << "\t.subsections_via_symbols\n";
- } else if (Subtarget->isTargetCygMing()) {
- // Emit type information for external functions
- for (StringSet<>::iterator i = CygMingStubs.begin(), e = CygMingStubs.end();
- i != e; ++i) {
- O << "\t.def\t " << i->getKeyData()
+ }
+
+ if (Subtarget->isTargetCOFF()) {
+ for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
+ I != E; ++I)
+ if (I->hasDLLExportLinkage())
+ DLLExportedGVs.insert(Mang->getMangledName(I));
+
+ if (Subtarget->isTargetCygMing()) {
+ // Emit type information for external functions
+ for (StringSet<>::iterator i = CygMingStubs.begin(), e = CygMingStubs.end();
+ i != e; ++i) {
+ O << "\t.def\t " << i->getKeyData()
<< ";\t.scl\t" << COFF::C_EXT
<< ";\t.type\t" << (COFF::DT_FCN << COFF::N_BTSHFT)
<< ";\t.endef\n";
+ }
+ }
+
+ // Output linker support code for dllexported globals on windows.
+ if (!DLLExportedGVs.empty() || !DLLExportedFns.empty()) {
+ // dllexport symbols only exist on coff targets.
+ TargetLoweringObjectFileCOFF &TLOFCOFF =
+ static_cast<TargetLoweringObjectFileCOFF&>(getObjFileLowering());
+
+ OutStreamer.SwitchSection(TLOFCOFF.getCOFFSection(".section .drectve",
+ true,
+ SectionKind::getMetadata()));
+
+ for (StringSet<>::iterator i = DLLExportedGVs.begin(),
+ e = DLLExportedGVs.end(); i != e; ++i)
+ O << "\t.ascii \" -export:" << i->getKeyData() << ",data\"\n";
+
+ for (StringSet<>::iterator i = DLLExportedFns.begin(),
+ e = DLLExportedFns.end();
+ i != e; ++i)
+ O << "\t.ascii \" -export:" << i->getKeyData() << "\"\n";
}
}
-
-
- // Output linker support code for dllexported globals on windows.
- if (!DLLExportedGVs.empty() || !DLLExportedFns.empty()) {
- // dllexport symbols only exist on coff targets.
- TargetLoweringObjectFileCOFF &TLOFMacho =
- static_cast<TargetLoweringObjectFileCOFF&>(getObjFileLowering());
-
- OutStreamer.SwitchSection(TLOFMacho.getCOFFSection(".section .drectve",true,
- SectionKind::getMetadata()));
-
- for (StringSet<>::iterator i = DLLExportedGVs.begin(),
- e = DLLExportedGVs.end(); i != e; ++i)
- O << "\t.ascii \" -export:" << i->getKeyData() << ",data\"\n";
-
- for (StringSet<>::iterator i = DLLExportedFns.begin(),
- e = DLLExportedFns.end();
- i != e; ++i)
- O << "\t.ascii \" -export:" << i->getKeyData() << "\"\n";
- }
-
+
// Do common shutdown.
return AsmPrinter::doFinalization(M);
}
diff --git a/lib/Target/X86/X86Subtarget.h b/lib/Target/X86/X86Subtarget.h
index 60c2745..a2e368d 100644
--- a/lib/Target/X86/X86Subtarget.h
+++ b/lib/Target/X86/X86Subtarget.h
@@ -148,12 +148,20 @@
bool isTargetDarwin() const { return TargetType == isDarwin; }
bool isTargetELF() const { return TargetType == isELF; }
+
bool isTargetWindows() const { return TargetType == isWindows; }
bool isTargetMingw() const { return TargetType == isMingw; }
+ bool isTargetCygwin() const { return TargetType == isCygwin; }
bool isTargetCygMing() const {
return TargetType == isMingw || TargetType == isCygwin;
}
- bool isTargetCygwin() const { return TargetType == isCygwin; }
+
+ /// isTargetCOFF - Return true if this is any COFF/Windows target variant.
+ bool isTargetCOFF() const {
+ return TargetType == isMingw || TargetType == isCygwin ||
+ TargetType == isWindows;
+ }
+
bool isTargetWin64() const {
return Is64Bit && (TargetType == isMingw || TargetType == isWindows);
}