[llvm-commits] [llvm] r93603 - in /llvm/trunk/lib/Target: Sparc/AsmPrinter/SparcAsmPrinter.cpp X86/AsmPrinter/X86AsmPrinter.cpp X86/X86COFFMachineModuleInfo.cpp X86/X86COFFMachineModuleInfo.h

Chris Lattner sabre at nondot.org
Fri Jan 15 16:51:39 PST 2010


Author: lattner
Date: Fri Jan 15 18:51:39 2010
New Revision: 93603

URL: http://llvm.org/viewvc/llvm-project?rev=93603&view=rev
Log:
switch X86 target off CurFunctionName and MCIze more.
Note that the code wasn't calling DecorateCygMingName
when emitting the ".ascii -export" stuff at the end of
file for DLLExported functions.  I don't know if it should
or not, but I'm preserving behavior.

Modified:
    llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp
    llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
    llvm/trunk/lib/Target/X86/X86COFFMachineModuleInfo.cpp
    llvm/trunk/lib/Target/X86/X86COFFMachineModuleInfo.h

Modified: llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp?rev=93603&r1=93602&r2=93603&view=diff

==============================================================================
--- llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp Fri Jan 15 18:51:39 2010
@@ -170,8 +170,9 @@
   case Function::WeakAnyLinkage:
   case Function::WeakODRLinkage:
     // Function is weak
-    O << "\t.weak\t";CurrentFnSym->print(O, MAI);
-    O << '\n' ;
+    O << "\t.weak\t";
+    CurrentFnSym->print(O, MAI);
+    O << '\n';
     break;
   }
   

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

==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Fri Jan 15 18:51:39 2010
@@ -71,8 +71,8 @@
   if (Subtarget->isTargetCygMing()) {
     X86COFFMachineModuleInfo &COFFMMI = 
       MMI->getObjFileInfo<X86COFFMachineModuleInfo>();
-    COFFMMI.DecorateCygMingName(CurrentFnName, F, *TM.getTargetData());
-    CurrentFnSym = OutContext.GetOrCreateSymbol(StringRef(CurrentFnName));
+    COFFMMI.DecorateCygMingName(CurrentFnSym, OutContext, F,
+                                *TM.getTargetData());
   }
 
   OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(F, Mang, TM));
@@ -238,24 +238,25 @@
   case MachineOperand::MO_GlobalAddress: {
     const GlobalValue *GV = MO.getGlobal();
     
-    const char *Suffix = "";
+    const MCSymbol *GVSym;
     if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB)
-      Suffix = "$stub";
+      GVSym = GetPrivateGlobalValueSymbolStub(GV, "$stub");
     else if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY ||
              MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE ||
              MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE)
-      Suffix = "$non_lazy_ptr";
-    
-    std::string Name = Mang->getMangledName(GV, Suffix, Suffix[0] != '\0');
+      GVSym = GetPrivateGlobalValueSymbolStub(GV, "$non_lazy_ptr");
+    else
+      GVSym = GetGlobalValueSymbol(GV);
+
     if (Subtarget->isTargetCygMing()) {
       X86COFFMachineModuleInfo &COFFMMI =
         MMI->getObjFileInfo<X86COFFMachineModuleInfo>();
-      COFFMMI.DecorateCygMingName(Name, GV, *TM.getTargetData());
+      COFFMMI.DecorateCygMingName(GVSym, OutContext, GV, *TM.getTargetData());
     }
     
     // Handle dllimport linkage.
     if (MO.getTargetFlags() == X86II::MO_DLLIMPORT)
-      Name = "__imp_" + Name;
+      GVSym = OutContext.GetOrCreateSymbol(Twine("__imp_") + GVSym->getName());
     
     if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY ||
         MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE) {
@@ -296,11 +297,13 @@
     
     // 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 (GVSym->getName()[0] != '$')
+      GVSym->print(O, MAI);
+    else {
+      O << '(';
+      GVSym->print(O, MAI);
+      O << ')';
+    }
     printOffset(MO.getOffset());
     break;
   }
@@ -916,36 +919,39 @@
 
     if (Subtarget->isTargetCygMing()) {
       // Necessary for dllexport support
-      std::vector<std::string> DLLExportedFns, DLLExportedGlobals;
+      std::vector<const MCSymbol*> DLLExportedFns, DLLExportedGlobals;
 
       TargetLoweringObjectFileCOFF &TLOFCOFF =
         static_cast<TargetLoweringObjectFileCOFF&>(getObjFileLowering());
 
       for (Module::const_iterator I = M.begin(), E = M.end(); I != E; ++I)
         if (I->hasDLLExportLinkage()) {
-          std::string Name = Mang->getMangledName(I);
-          COFFMMI.DecorateCygMingName(Name, I, *TM.getTargetData());
-          DLLExportedFns.push_back(Name);
+          const MCSymbol *Sym = GetGlobalValueSymbol(I);
+          COFFMMI.DecorateCygMingName(Sym, OutContext, I, *TM.getTargetData());
+          DLLExportedFns.push_back(Sym);
         }
 
       for (Module::const_global_iterator I = M.global_begin(),
              E = M.global_end(); I != E; ++I)
-        if (I->hasDLLExportLinkage()) {
-          std::string Name = Mang->getMangledName(I);
-          COFFMMI.DecorateCygMingName(Name, I, *TM.getTargetData());
-          DLLExportedGlobals.push_back(Mang->getMangledName(I));
-        }
+        if (I->hasDLLExportLinkage())
+          DLLExportedGlobals.push_back(GetGlobalValueSymbol(I));
 
       // Output linker support code for dllexported globals on windows.
       if (!DLLExportedGlobals.empty() || !DLLExportedFns.empty()) {
         OutStreamer.SwitchSection(TLOFCOFF.getCOFFSection(".section .drectve",
                                                           true,
                                                    SectionKind::getMetadata()));
-        for (unsigned i = 0, e = DLLExportedGlobals.size(); i != e; ++i)
-          O << "\t.ascii \" -export:" << DLLExportedGlobals[i] << ",data\"\n";
+        for (unsigned i = 0, e = DLLExportedGlobals.size(); i != e; ++i) {
+          O << "\t.ascii \" -export:";
+          DLLExportedGlobals[i]->print(O, MAI);
+          O << ",data\"\n";
+        }
 
-        for (unsigned i = 0, e = DLLExportedFns.size(); i != e; ++i)
-          O << "\t.ascii \" -export:" << DLLExportedFns[i] << "\"\n";
+        for (unsigned i = 0, e = DLLExportedFns.size(); i != e; ++i) {
+          O << "\t.ascii \" -export:";
+          DLLExportedFns[i]->print(O, MAI);
+          O << "\"\n";
+        }
       }
     }
   }

Modified: llvm/trunk/lib/Target/X86/X86COFFMachineModuleInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86COFFMachineModuleInfo.cpp?rev=93603&r1=93602&r2=93603&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86COFFMachineModuleInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86COFFMachineModuleInfo.cpp Fri Jan 15 18:51:39 2010
@@ -15,6 +15,8 @@
 #include "X86MachineFunctionInfo.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Function.h"
+#include "llvm/MC/MCContext.h"
+#include "llvm/MC/MCSymbol.h"
 #include "llvm/Target/TargetData.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/raw_ostream.h"
@@ -23,7 +25,6 @@
 X86COFFMachineModuleInfo::X86COFFMachineModuleInfo(const MachineModuleInfo &) {
 }
 X86COFFMachineModuleInfo::~X86COFFMachineModuleInfo() {
-  
 }
 
 void X86COFFMachineModuleInfo::AddFunctionInfo(const Function *F,
@@ -114,10 +115,12 @@
 
 /// DecorateCygMingName - Query FunctionInfoMap and use this information for
 /// various name decorations for Cygwin and MingW.
-void X86COFFMachineModuleInfo::DecorateCygMingName(std::string &Name,
+void X86COFFMachineModuleInfo::DecorateCygMingName(const MCSymbol *&Name,
+                                                   MCContext &Ctx,
                                                    const GlobalValue *GV,
                                                    const TargetData &TD) {
-  SmallString<128> NameStr(Name.begin(), Name.end());
+  SmallString<128> NameStr(Name->getName().begin(), Name->getName().end());
   DecorateCygMingName(NameStr, GV, TD);
-  Name.assign(NameStr.begin(), NameStr.end());
+  
+  Name = Ctx.GetOrCreateSymbol(NameStr.str());
 }

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

==============================================================================
--- llvm/trunk/lib/Target/X86/X86COFFMachineModuleInfo.h (original)
+++ llvm/trunk/lib/Target/X86/X86COFFMachineModuleInfo.h Fri Jan 15 18:51:39 2010
@@ -46,8 +46,8 @@
   ~X86COFFMachineModuleInfo();
   
   
-  void DecorateCygMingName(std::string &Name, const GlobalValue *GV,
-                           const TargetData &TD);
+  void DecorateCygMingName(const MCSymbol* &Name, MCContext &Ctx,
+                           const GlobalValue *GV, const TargetData &TD);
   void DecorateCygMingName(SmallVectorImpl<char> &Name, const GlobalValue *GV,
                            const TargetData &TD);
   





More information about the llvm-commits mailing list