[llvm-commits] [llvm] r82010 - in /llvm/trunk/lib/Target/X86: AsmPrinter/X86ATTAsmPrinter.cpp X86Subtarget.h

Chris Lattner sabre at nondot.org
Tue Sep 15 22:20:33 PDT 2009


Author: lattner
Date: Wed Sep 16 00:20:33 2009
New Revision: 82010

URL: http://llvm.org/viewvc/llvm-project?rev=82010&view=rev
Log:
rearrange X86ATTAsmPrinter::doFinalization, making a scan of 
the global variable list only happen for COFF targets.

Modified:
    llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
    llvm/trunk/lib/Target/X86/X86Subtarget.h

Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=82010&r1=82009&r2=82010&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Wed Sep 16 00:20:33 2009
@@ -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 &TLOFMacho = 
-      static_cast<TargetLoweringObjectFileCOFF&>(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<TargetLoweringObjectFileCOFF&>(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);
 }

Modified: llvm/trunk/lib/Target/X86/X86Subtarget.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.h?rev=82010&r1=82009&r2=82010&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86Subtarget.h (original)
+++ llvm/trunk/lib/Target/X86/X86Subtarget.h Wed Sep 16 00:20:33 2009
@@ -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);
   }





More information about the llvm-commits mailing list