[llvm-commits] [llvm] r75718 - /llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp

Chris Lattner sabre at nondot.org
Tue Jul 14 17:55:59 PDT 2009


Author: lattner
Date: Tue Jul 14 19:55:58 2009
New Revision: 75718

URL: http://llvm.org/viewvc/llvm-project?rev=75718&view=rev
Log:
minor cleanups: only switch sections once before all function stubs, instead of
before each one.

Modified:
    llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp

Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=75718&r1=75717&r2=75718&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Tue Jul 14 19:55:58 2009
@@ -366,7 +366,8 @@
   case MachineOperand::MO_ExternalSymbol:
     // Computing the address of an external symbol, not calling it.
     if (TM.getRelocationModel() != Reloc::Static) {
-      std::string Name(TAI->getGlobalPrefix()); Name += MO.getSymbolName();
+      std::string Name(TAI->getGlobalPrefix());
+      Name += MO.getSymbolName();
       GVStubs.insert(Name);
       printSuffixedName(Name, "$non_lazy_ptr");
       return;
@@ -381,17 +382,15 @@
     // External or weakly linked global variables need non-lazily-resolved stubs
     if (TM.getRelocationModel() != Reloc::Static) {
       if (GV->isDeclaration() || GV->isWeakForLinker()) {
-        if (GV->hasHiddenVisibility()) {
-          if (GV->isDeclaration() || GV->hasCommonLinkage() ||
-              GV->hasAvailableExternallyLinkage()) {
-            HiddenGVStubs.insert(Name);
-            printSuffixedName(Name, "$non_lazy_ptr");
-          } else {
-            O << Name;
-          }
-        } else {
+        if (!GV->hasHiddenVisibility()) {
           GVStubs.insert(Name);
           printSuffixedName(Name, "$non_lazy_ptr");
+        } else if (GV->isDeclaration() || GV->hasCommonLinkage() ||
+                   GV->hasAvailableExternallyLinkage()) {
+          HiddenGVStubs.insert(Name);
+          printSuffixedName(Name, "$non_lazy_ptr");
+        } else {
+          O << Name;
         }
         return;
       }
@@ -962,11 +961,11 @@
   bool isPPC64 = TD->getPointerSizeInBits() == 64;
 
   // Output stubs for dynamically-linked functions
-  if (TM.getRelocationModel() == Reloc::PIC_) {
+  if (TM.getRelocationModel() == Reloc::PIC_ && !FnStubs.empty()) {
+    SwitchToTextSection("\t.section __TEXT,__picsymbolstub1,symbol_stubs,"
+                        "pure_instructions,32");
     for (StringSet<>::iterator i = FnStubs.begin(), e = FnStubs.end();
          i != e; ++i) {
-      SwitchToTextSection("\t.section __TEXT,__picsymbolstub1,symbol_stubs,"
-                          "pure_instructions,32");
       EmitAlignment(4);
       const char *p = i->getKeyData();
       bool hasQuote = p[0]=='\"';
@@ -1017,11 +1016,11 @@
       else
         O << "\t.long dyld_stub_binding_helper\n";
     }
-  } else {
+  } else if (!FnStubs.empty()) {
+    SwitchToTextSection("\t.section __TEXT,__symbol_stub1,symbol_stubs,"
+                        "pure_instructions,16");
     for (StringSet<>::iterator i = FnStubs.begin(), e = FnStubs.end();
          i != e; ++i) {
-      SwitchToTextSection("\t.section __TEXT,__symbol_stub1,symbol_stubs,"
-                          "pure_instructions,16");
       EmitAlignment(4);
       const char *p = i->getKeyData();
       printSuffixedName(p, "$stub");





More information about the llvm-commits mailing list