From: Chris Lattner Date: Wed, 16 Sep 2009 05:20:33 +0000 (+0000) Subject: rearrange X86ATTAsmPrinter::doFinalization, making a scan of X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=a76e3fc131792fa6a88807c3120c59c8632bfb9e;p=oota-llvm.git 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 c2c3855df72..4085f984418 100644 --- a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp +++ b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp @@ -889,13 +889,6 @@ GetSortedStubs(const DenseMap &Map) { } 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 @@ bool X86ATTAsmPrinter::doFinalization(Module &M) { // 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 &Personalities = MMI->getPersonalities(); for (unsigned i = 0, e = Personalities.size(); i != e; ++i) { if (Personalities[i] == 0) @@ -984,37 +977,46 @@ bool X86ATTAsmPrinter::doFinalization(Module &M) { // 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 &TLOFMacho = - static_cast(getObjFileLowering()); + // 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(getObjFileLowering()); + + OutStreamer.SwitchSection(TLOFCOFF.getCOFFSection(".section .drectve", + true, + SectionKind::getMetadata())); - 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"; + 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 60c27452c86..a2e368de6f0 100644 --- a/lib/Target/X86/X86Subtarget.h +++ b/lib/Target/X86/X86Subtarget.h @@ -148,12 +148,20 @@ public: 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); }