diff --git a/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp index b879d48ce05..cc80e20fb1c 100644 --- a/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp +++ b/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp @@ -61,10 +61,8 @@ MCSymbol *X86AsmPrinter::GetGlobalValueSymbol(const GlobalValue *GV) const { X86COFFMachineModuleInfo &COFFMMI = MMI->getObjFileInfo(); - COFFMMI.DecorateCygMingName(Symb, OutContext, cast(GV), - *TM.getTargetData()); - - return Symb; + return COFFMMI.DecorateCygMingName(Symb, OutContext, cast(GV), + *TM.getTargetData()); } /// runOnMachineFunction - Emit the function body. diff --git a/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp b/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp index 8dabaac6d19..537d44222f0 100644 --- a/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp +++ b/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp @@ -65,8 +65,8 @@ GetSymbolFromOperand(const MachineOperand &MO) const { MCSymbol *Sym = Mang->getSymbol(GV); X86COFFMachineModuleInfo &COFFMMI = AsmPrinter.MMI->getObjFileInfo(); - COFFMMI.DecorateCygMingName(Sym, Ctx, cast(GV), - *AsmPrinter.TM.getTargetData()); + Sym = COFFMMI.DecorateCygMingName(Sym, Ctx, cast(GV), + *AsmPrinter.TM.getTargetData()); Name.append(Sym->getName().begin(), Sym->getName().end()); } else { const GlobalValue *GV = MO.getGlobal(); diff --git a/lib/Target/X86/X86COFFMachineModuleInfo.cpp b/lib/Target/X86/X86COFFMachineModuleInfo.cpp index 8fbd20714d6..2988e4f91d0 100644 --- a/lib/Target/X86/X86COFFMachineModuleInfo.cpp +++ b/lib/Target/X86/X86COFFMachineModuleInfo.cpp @@ -28,16 +28,14 @@ X86COFFMachineModuleInfo::~X86COFFMachineModuleInfo() { /// DecorateCygMingName - Query FunctionInfoMap and use this information for /// various name decorations for Cygwin and MingW. -void X86COFFMachineModuleInfo::DecorateCygMingName(MCSymbol *&NameSym, - MCContext &Ctx, - const Function *F, - const TargetData &TD) { - SmallString<128> Name(NameSym->getName().begin(), NameSym->getName().end()); - +MCSymbol *X86COFFMachineModuleInfo::DecorateCygMingName(MCSymbol *NameSym, + MCContext &Ctx, + const Function *F, + const TargetData &TD) { // We don't want to decorate non-stdcall or non-fastcall functions right now CallingConv::ID CC = F->getCallingConv(); if (CC != CallingConv::X86_StdCall && CC != CallingConv::X86_FastCall) - return; + return NameSym; unsigned ArgWords = 0; @@ -55,6 +53,9 @@ void X86COFFMachineModuleInfo::DecorateCygMingName(MCSymbol *&NameSym, } const FunctionType *FT = F->getFunctionType(); + + SmallString<128> Name(NameSym->getName().begin(), NameSym->getName().end()); + // "Pure" variadic functions do not receive @0 suffix. if (!FT->isVarArg() || FT->getNumParams() == 0 || (FT->getNumParams() == 1 && F->hasStructRetAttr())) @@ -67,5 +68,5 @@ void X86COFFMachineModuleInfo::DecorateCygMingName(MCSymbol *&NameSym, Name.insert(Name.begin(), '@'); } - NameSym = Ctx.GetOrCreateSymbol(Name.str()); + return Ctx.GetOrCreateSymbol(Name.str()); } diff --git a/lib/Target/X86/X86COFFMachineModuleInfo.h b/lib/Target/X86/X86COFFMachineModuleInfo.h index f43b5ce7cbb..d07f0733535 100644 --- a/lib/Target/X86/X86COFFMachineModuleInfo.h +++ b/lib/Target/X86/X86COFFMachineModuleInfo.h @@ -30,8 +30,8 @@ public: X86COFFMachineModuleInfo(const MachineModuleInfo &) {} virtual ~X86COFFMachineModuleInfo(); - void DecorateCygMingName(MCSymbol *&Name, MCContext &Ctx, - const Function *F, const TargetData &TD); + MCSymbol *DecorateCygMingName(MCSymbol *Name, MCContext &Ctx, + const Function *F, const TargetData &TD); void addExternalFunction(StringRef Name) { CygMingStubs.insert(Name);