[llvm-commits] [llvm] r75636 - in /llvm/trunk: include/llvm/Support/Mangler.h lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp lib/VMCore/Mangler.cpp test/CodeGen/X86/loop-hoist.ll

Daniel Dunbar daniel at zuster.org
Tue Jul 14 08:57:56 PDT 2009


Author: ddunbar
Date: Tue Jul 14 10:57:55 2009
New Revision: 75636

URL: http://llvm.org/viewvc/llvm-project?rev=75636&view=rev
Log:
Revert r75610 (and r75620, which was blocking the revert), in the hopes of
unbreaking llvm-gcc (on Darwin).

--- Reverse-merging r75620 into '.':
U    include/llvm/Support/Mangler.h
--- Reverse-merging r75610 into '.':
U    test/CodeGen/X86/loop-hoist.ll
G    include/llvm/Support/Mangler.h
U    lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
U    lib/VMCore/Mangler.cpp

Modified:
    llvm/trunk/include/llvm/Support/Mangler.h
    llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
    llvm/trunk/lib/VMCore/Mangler.cpp
    llvm/trunk/test/CodeGen/X86/loop-hoist.ll

Modified: llvm/trunk/include/llvm/Support/Mangler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Mangler.h?rev=75636&r1=75635&r2=75636&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Support/Mangler.h (original)
+++ llvm/trunk/include/llvm/Support/Mangler.h Tue Jul 14 10:57:55 2009
@@ -82,13 +82,10 @@
     return (AcceptableChars[X/32] & (1 << (X&31))) != 0;
   }
 
-  /// getMangledName - Returns the mangled name of V, an LLVM Value,
-  /// in the current module.  If 'Suffix' is specified, the name ends with the
-  /// specified suffix.  If 'ForcePrivate' is specified, the label is specified
-  /// to have a private label prefix.
+  /// getValueName - Returns the mangled name of V, an LLVM Value,
+  /// in the current module.
   ///
-  std::string getMangledName(const GlobalValue *V, const char *Suffix = "",
-                             bool ForcePrivate = false);
+  std::string getValueName(const GlobalValue *V, const char *Suffix = "");
 
   /// makeNameProper - We don't want identifier names with ., space, or
   /// - in them, so we mangle these characters into the strings "d_",

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=75636&r1=75635&r2=75636&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Tue Jul 14 10:57:55 2009
@@ -233,7 +233,7 @@
   EmitConstantPool(MF.getConstantPool());
 
   if (F->hasDLLExportLinkage())
-    DLLExportedFns.insert(Mang->getMangledName(F));
+    DLLExportedFns.insert(Mang->getValueName(F));
 
   // Print the 'header' of function
   emitFunctionHeader(MF);
@@ -304,58 +304,62 @@
     break;
   case MachineOperand::MO_GlobalAddress: {
     const GlobalValue *GV = MO.getGlobal();
-    
-    const char *Suffix = "";
-    
-    if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB)
-      Suffix = "$stub";
-    else if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY ||
-             MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE ||
-             MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY ||
-             MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE)
-      Suffix = "$non_lazy_ptr";
-    
-    std::string Name = Mang->getMangledName(GV, Suffix, Suffix[0] != '\0');
+    std::string Name = Mang->getValueName(GV);
     decorateName(Name, GV);
     
-    // Handle dllimport linkage.
-    if (MO.getTargetFlags() == X86II::MO_DLLIMPORT)
-      Name = "__imp_" + Name;
+    bool needCloseParen = false;
+    if (Name[0] == '$') {
+      // The name begins with a dollar-sign. In order to avoid having it look
+      // like an integer immediate to the assembler, enclose it in parens.
+      O << '(';
+      needCloseParen = true;
+    }
     
-    if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY ||
-        MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE)
+    // Handle dllimport linkage.
+    if (MO.getTargetFlags() == X86II::MO_DLLIMPORT) {
+      O << "__imp_" << Name;
+    } else if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY ||
+               MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE) {
       GVStubs.insert(Name);
-    else if (MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY ||
-             MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE)
+      printSuffixedName(Name, "$non_lazy_ptr");
+    } else if (MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY ||
+               MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE){
       HiddenGVStubs.insert(Name);
-    else if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB)
+      printSuffixedName(Name, "$non_lazy_ptr");
+    } else if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) {
       FnStubs.insert(Name);
-    
-    // If the name begins with a dollar-sign, enclose it in parens.  We do this
-    // to avoid having it look like an integer immediate to the assembler.
-    if (Name[0] == '$') 
-      O << '(' << Name << ')';
-    else
+      printSuffixedName(Name, "$stub");
+    } else {
       O << Name;
+    }
+    
+    if (needCloseParen)
+      O << ')';
     
     printOffset(MO.getOffset());
     break;
   }
   case MachineOperand::MO_ExternalSymbol: {
+    bool needCloseParen = false;
     std::string Name(TAI->getGlobalPrefix());
     Name += MO.getSymbolName();
-
+    
+    if (Name[0] == '$') {
+      // The name begins with a dollar-sign. In order to avoid having it look
+      // like an integer immediate to the assembler, enclose it in parens.
+      O << '(';
+      needCloseParen = true;
+    }
+    
     if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) {
-      Name += "$stub";
       FnStubs.insert(Name);
+      printSuffixedName(Name, "$stub");
+    } else {
+      O << Name;
     }
     
-    // If the name begins with a dollar-sign, enclose it in parens.  We do this
-    // to avoid having it look like an integer immediate to the assembler.
-    if (Name[0] == '$') 
-      O << '(' << Name << ')';
-    else
-      O << Name;
+    if (needCloseParen)
+      O << ')';
     break;
   }
   }
@@ -783,7 +787,7 @@
     return;
   }
 
-  std::string name = Mang->getMangledName(GVar);
+  std::string name = Mang->getValueName(GVar);
   Constant *C = GVar->getInitializer();
   if (isa<MDNode>(C) || isa<MDString>(C))
     return;
@@ -899,20 +903,6 @@
   EmitGlobalConstant(C);
 }
 
-/// PrintWithoutDarwinSuffix - Print a name that has a suffix appended to it
-/// without the suffix.  This is used for darwin stub emission, where we have to
-/// be careful to remove the suffix even if the name is quoted.
-static void PrintWithoutDarwinSuffix(const char *Name, unsigned NameLen,
-                                     unsigned SuffixLen, raw_ostream &O) {
-  assert(NameLen > SuffixLen && "Invalid empty name or bogus suffix");
-  if (Name[NameLen-1] != '"') {
-    O.write(Name, NameLen-SuffixLen);  // foo$stub -> foo
-  } else {
-    O.write(Name, NameLen-SuffixLen-1);  // "foo$stub" -> "foo
-    O << '"';                            //            -> "
-  }
-}
-
 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();
@@ -920,7 +910,7 @@
     printModuleLevelGV(I);
 
     if (I->hasDLLExportLinkage())
-      DLLExportedGVs.insert(Mang->getMangledName(I));
+      DLLExportedGVs.insert(Mang->getValueName(I));
   }
 
   if (Subtarget->isTargetDarwin()) {
@@ -931,10 +921,11 @@
     if (TAI->doesSupportExceptionHandling() && MMI && !Subtarget->is64Bit()) {
       const std::vector<Function*> &Personalities = MMI->getPersonalities();
       for (unsigned i = 0, e = Personalities.size(); i != e; ++i) {
-        if (Personalities[i])
-          GVStubs.insert(Mang->getMangledName(Personalities[i],
-                                              "$non_lazy_ptr",
-                                              true /*private label*/));
+        if (Personalities[i] == 0)
+          continue;
+        std::string Name = Mang->getValueName(Personalities[i]);
+        decorateName(Name, Personalities[i]);
+        GVStubs.insert(Name);
       }
     }
 
@@ -945,13 +936,10 @@
         SwitchToDataSection("\t.section __IMPORT,__jump_table,symbol_stubs,"
                             "self_modifying_code+pure_instructions,5", 0);
         const char *Name = I->getKeyData();
-        O << Name << ":\n";
-        O << "\t.indirect_symbol ";
-        
-        // Print the name without the $stub.
-        PrintWithoutDarwinSuffix(Name, I->getKeyLength(), strlen("$stub"), O);
-        O << '\n';
-        O << "\thlt ; hlt ; hlt ; hlt ; hlt\n";
+        printSuffixedName(Name, "$stub");
+        O << ":\n"
+             "\t.indirect_symbol " << Name << "\n"
+             "\thlt ; hlt ; hlt ; hlt ; hlt\n";
       }
       O << '\n';
     }
@@ -963,10 +951,8 @@
       for (StringSet<>::iterator I = GVStubs.begin(), E = GVStubs.end();
            I != E; ++I) {
         const char *Name = I->getKeyData();
-        O << Name << ":\n\t.indirect_symbol ";
-        PrintWithoutDarwinSuffix(Name, I->getKeyLength(),
-                                 strlen("$non_lazy_ptr"), O);
-        O << "\n\t.long\t0\n";
+        printSuffixedName(Name, "$non_lazy_ptr");
+        O << ":\n\t.indirect_symbol " << Name << "\n\t.long\t0\n";
       }
     }
 
@@ -976,10 +962,8 @@
       for (StringSet<>::iterator I = HiddenGVStubs.begin(),
            E = HiddenGVStubs.end(); I != E; ++I) {
         const char *Name = I->getKeyData();
-        O << Name << ":\n" << TAI->getData32bitsDirective();
-        PrintWithoutDarwinSuffix(Name, I->getKeyLength(),
-                                 strlen("$non_lazy_ptr"), O);
-        O << '\n';
+        printSuffixedName(Name, "$non_lazy_ptr");
+        O << ":\n" << TAI->getData32bitsDirective() << Name << '\n';
       }
     }
 

Modified: llvm/trunk/lib/VMCore/Mangler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Mangler.cpp?rev=75636&r1=75635&r2=75636&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Mangler.cpp (original)
+++ llvm/trunk/lib/VMCore/Mangler.cpp Tue Jul 14 10:57:55 2009
@@ -116,19 +116,12 @@
   return Result;
 }
 
-/// getMangledName - Returns the mangled name of V, an LLVM Value,
-/// in the current module.  If 'Suffix' is specified, the name ends with the
-/// specified suffix.  If 'ForcePrivate' is specified, the label is specified
-/// to have a private label prefix.
-///
-std::string Mangler::getMangledName(const GlobalValue *GV, const char *Suffix,
-                                    bool ForcePrivate) {
+std::string Mangler::getValueName(const GlobalValue *GV, const char *Suffix) {
   assert((!isa<Function>(GV) || !cast<Function>(GV)->isIntrinsic()) &&
          "Intrinsic functions cannot be mangled by Mangler");
   
   if (GV->hasName())
-    return makeNameProper(GV->getName() + Suffix,
-                          GV->hasPrivateLinkage() | ForcePrivate);
+    return makeNameProper(GV->getName() + Suffix, GV->hasPrivateLinkage());
   
   // Get the ID for the global, assigning a new one if we haven't got one
   // already.
@@ -136,8 +129,7 @@
   if (ID == 0) ID = NextAnonGlobalID++;
   
   // Must mangle the global into a unique ID.
-  return makeNameProper("__unnamed_" + utostr(ID) + Suffix,
-                        GV->hasPrivateLinkage() | ForcePrivate);
+  return "__unnamed_" + utostr(ID) + Suffix;
 }
 
 Mangler::Mangler(Module &M, const char *prefix, const char *privatePrefix)

Modified: llvm/trunk/test/CodeGen/X86/loop-hoist.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/loop-hoist.ll?rev=75636&r1=75635&r2=75636&view=diff

==============================================================================
--- llvm/trunk/test/CodeGen/X86/loop-hoist.ll (original)
+++ llvm/trunk/test/CodeGen/X86/loop-hoist.ll Tue Jul 14 10:57:55 2009
@@ -1,10 +1,10 @@
 ; RUN: llvm-as < %s | \
 ; RUN:   llc -relocation-model=dynamic-no-pic -mtriple=i686-apple-darwin8.7.2 |\
-; RUN:   grep LArr.non_lazy_ptr
+; RUN:   grep L_Arr.non_lazy_ptr
 ; RUN: llvm-as < %s | \
 ; RUN:   llc -disable-post-RA-scheduler=true \
 ; RUN:       -relocation-model=dynamic-no-pic -mtriple=i686-apple-darwin8.7.2 |\
-; RUN:   %prcontext LArr.non_lazy_ptr 1 | grep {4(%esp)}
+; RUN:   %prcontext L_Arr.non_lazy_ptr 1 | grep {4(%esp)}
 
 @Arr = external global [0 x i32]		; <[0 x i32]*> [#uses=1]
 





More information about the llvm-commits mailing list