diff options
Diffstat (limited to 'llvm')
27 files changed, 174 insertions, 176 deletions
diff --git a/llvm/include/llvm/Support/Mangler.h b/llvm/include/llvm/Support/Mangler.h index 0dc26edc2df..0578f8f2b47 100644 --- a/llvm/include/llvm/Support/Mangler.h +++ b/llvm/include/llvm/Support/Mangler.h @@ -82,10 +82,13 @@ public:      return (AcceptableChars[X/32] & (1 << (X&31))) != 0;    } -  /// getValueName - Returns the mangled name of V, an LLVM Value, -  /// in the current module. +  /// 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 getValueName(const GlobalValue *V, const char *Suffix = ""); +  std::string getMangledName(const GlobalValue *V, const char *Suffix = "", +                             bool ForcePrivate = false);    /// makeNameProper - We don't want identifier names with ., space, or    /// - in them, so we mangle these characters into the strings "d_", diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index d0b0aab0a8e..7e1d413fd1e 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -210,13 +210,13 @@ bool AsmPrinter::doFinalization(Module &M) {      for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();           I != E; ++I) {        if (I->hasExternalWeakLinkage()) -        O << TAI->getWeakRefDirective() << Mang->getValueName(I) << '\n'; +        O << TAI->getWeakRefDirective() << Mang->getMangledName(I) << '\n';      }      for (Module::const_iterator I = M.begin(), E = M.end();           I != E; ++I) {        if (I->hasExternalWeakLinkage()) -        O << TAI->getWeakRefDirective() << Mang->getValueName(I) << '\n'; +        O << TAI->getWeakRefDirective() << Mang->getMangledName(I) << '\n';      }    } @@ -227,11 +227,10 @@ bool AsmPrinter::doFinalization(Module &M) {      O << '\n';      for (Module::const_alias_iterator I = M.alias_begin(), E = M.alias_end();           I != E; ++I) { -      std::string Name = Mang->getValueName(I); -      std::string Target; +      std::string Name = Mang->getMangledName(I);        const GlobalValue *GV = cast<GlobalValue>(I->getAliasedGlobal()); -      Target = Mang->getValueName(GV); +      std::string Target = Mang->getMangledName(GV);        if (I->hasExternalLinkage() || !TAI->getWeakRefDirective())          O << "\t.globl\t" << Name << '\n'; @@ -270,15 +269,16 @@ AsmPrinter::getCurrentFunctionEHName(const MachineFunction *MF,    assert(MF && "No machine function?");    Name = MF->getFunction()->getName();    if (Name.empty()) -    Name = Mang->getValueName(MF->getFunction()); +    Name = Mang->getMangledName(MF->getFunction()); +  // FIXME: THIS SEEMS REALLY WRONG, it will get two prefixes.    Name = Mang->makeNameProper(TAI->getEHGlobalPrefix() + Name + ".eh");    return Name;  }  void AsmPrinter::SetupMachineFunction(MachineFunction &MF) {    // What's my mangled name? -  CurrentFnName = Mang->getValueName(MF.getFunction()); +  CurrentFnName = Mang->getMangledName(MF.getFunction());    IncrementFunctionNumber();  } @@ -576,11 +576,11 @@ const std::string &AsmPrinter::getGlobalLinkName(const GlobalVariable *GV,                                                   std::string &LinkName) const {    if (isa<Function>(GV)) {      LinkName += TAI->getFunctionAddrPrefix(); -    LinkName += Mang->getValueName(GV); +    LinkName += Mang->getMangledName(GV);      LinkName += TAI->getFunctionAddrSuffix();    } else {      LinkName += TAI->getGlobalVarAddrPrefix(); -    LinkName += Mang->getValueName(GV); +    LinkName += Mang->getMangledName(GV);      LinkName += TAI->getGlobalVarAddrSuffix();    }   @@ -858,11 +858,11 @@ void AsmPrinter::EmitConstantValueOnly(const Constant *CV) {      // FunctionAddrPrefix/Suffix (these all default to "" )      if (isa<Function>(GV)) {        O << TAI->getFunctionAddrPrefix() -        << Mang->getValueName(GV) +        << Mang->getMangledName(GV)          << TAI->getFunctionAddrSuffix();      } else {        O << TAI->getGlobalVarAddrPrefix() -        << Mang->getValueName(GV) +        << Mang->getMangledName(GV)          << TAI->getGlobalVarAddrSuffix();      }    } else if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(CV)) { diff --git a/llvm/lib/CodeGen/ELFWriter.cpp b/llvm/lib/CodeGen/ELFWriter.cpp index e041bd34eee..05b736147c4 100644 --- a/llvm/lib/CodeGen/ELFWriter.cpp +++ b/llvm/lib/CodeGen/ELFWriter.cpp @@ -601,7 +601,7 @@ void ELFWriter::EmitStringTable() {      // Use the name mangler to uniquify the LLVM symbol.      std::string Name; -    if (I->GV) Name.append(Mang->getValueName(I->GV)); +    if (I->GV) Name.append(Mang->getMangledName(I->GV));      if (Name.empty()) {        I->NameIdx = 0; diff --git a/llvm/lib/CodeGen/MachOCodeEmitter.cpp b/llvm/lib/CodeGen/MachOCodeEmitter.cpp index 14ebc3ff59f..77092769a94 100644 --- a/llvm/lib/CodeGen/MachOCodeEmitter.cpp +++ b/llvm/lib/CodeGen/MachOCodeEmitter.cpp @@ -60,7 +60,7 @@ void MachOCodeEmitter::startFunction(MachineFunction &MF) {    // Create symbol for function entry    const GlobalValue *FuncV = MF.getFunction(); -  MachOSym FnSym(FuncV, MOW.Mang->getValueName(FuncV), MOS->Index, TAI); +  MachOSym FnSym(FuncV, MOW.Mang->getMangledName(FuncV), MOS->Index, TAI);    FnSym.n_value = getCurrentPCOffset();    // add it to the symtab. diff --git a/llvm/lib/CodeGen/MachOWriter.cpp b/llvm/lib/CodeGen/MachOWriter.cpp index 5cbe6fd5c93..d19b218b2f3 100644 --- a/llvm/lib/CodeGen/MachOWriter.cpp +++ b/llvm/lib/CodeGen/MachOWriter.cpp @@ -221,7 +221,7 @@ void MachOWriter::AddSymbolToSection(MachOSection *Sec, GlobalVariable *GV) {    }    // Globals without external linkage apparently do not go in the symbol table.    if (!GV->hasLocalLinkage()) { -    MachOSym Sym(GV, Mang->getValueName(GV), Sec->Index, TAI); +    MachOSym Sym(GV, Mang->getMangledName(GV), Sec->Index, TAI);      Sym.n_value = Sec->size();      SymbolTable.push_back(Sym);    } @@ -255,7 +255,7 @@ void MachOWriter::EmitGlobal(GlobalVariable *GV) {      // merged with other symbols.      if (NoInit || GV->hasLinkOnceLinkage() || GV->hasWeakLinkage() ||          GV->hasCommonLinkage()) { -      MachOSym ExtOrCommonSym(GV, Mang->getValueName(GV), +      MachOSym ExtOrCommonSym(GV, Mang->getMangledName(GV),                                MachOSym::NO_SECT, TAI);        // For undefined (N_UNDF) external (N_EXT) types, n_value is the size in        // bytes of the symbol. @@ -454,7 +454,7 @@ void MachOWriter::BufferSymbolAndStringTable() {    for (std::vector<GlobalValue*>::iterator I = PendingGlobals.begin(),           E = PendingGlobals.end(); I != E; ++I) {      if (GVOffset[*I] == 0 && GVSection[*I] == 0) { -      MachOSym UndfSym(*I, Mang->getValueName(*I), MachOSym::NO_SECT, TAI); +      MachOSym UndfSym(*I, Mang->getMangledName(*I), MachOSym::NO_SECT, TAI);        SymbolTable.push_back(UndfSym);        GVOffset[*I] = -1;      } diff --git a/llvm/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp b/llvm/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp index f878a768f69..331d7aba058 100644 --- a/llvm/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp +++ b/llvm/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp @@ -155,9 +155,11 @@ namespace {        ARMConstantPoolValue *ACPV = static_cast<ARMConstantPoolValue*>(MCPV);        GlobalValue *GV = ACPV->getGV(); -      std::string Name = GV ? Mang->getValueName(GV) : TAI->getGlobalPrefix(); -      if (!GV) -        Name += ACPV->getSymbol(); +      std::string Name; +      if (GV) +        Name = Mang->getMangledName(GV); +      else +        Name = std::string(TAI->getGlobalPrefix()) + ACPV->getSymbol();        if (ACPV->isNonLazyPointer()) {          if (GV->hasHiddenVisibility())            HiddenGVNonLazyPtrs.insert(Name); @@ -324,7 +326,7 @@ void ARMAsmPrinter::printOperand(const MachineInstr *MI, int OpNum,    case MachineOperand::MO_GlobalAddress: {      bool isCallOp = Modifier && !strcmp(Modifier, "call");      GlobalValue *GV = MO.getGlobal(); -    std::string Name = Mang->getValueName(GV); +    std::string Name = Mang->getMangledName(GV);      bool isExt = (GV->isDeclaration() || GV->hasWeakLinkage() ||                    GV->hasLinkOnceLinkage());      if (isExt && isCallOp && Subtarget->isTargetDarwin() && @@ -1037,7 +1039,7 @@ void ARMAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {      return;    } -  std::string name = Mang->getValueName(GVar); +  std::string name = Mang->getMangledName(GVar);    Constant *C = GVar->getInitializer();    if (isa<MDNode>(C) || isa<MDString>(C))      return; diff --git a/llvm/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp b/llvm/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp index 1e3e83c8410..f43a3941230 100644 --- a/llvm/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp +++ b/llvm/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp @@ -117,11 +117,9 @@ void AlphaAsmPrinter::printOp(const MachineOperand &MO, bool IsCallOp) {      O << MO.getSymbolName();      return; -  case MachineOperand::MO_GlobalAddress: { -    GlobalValue *GV = MO.getGlobal(); -    O << Mang->getValueName(GV); +  case MachineOperand::MO_GlobalAddress: +    O << Mang->getMangledName(MO.getGlobal());      return; -  }    case MachineOperand::MO_JumpTableIndex:      O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() @@ -218,7 +216,7 @@ void AlphaAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {    if (EmitSpecialLLVMGlobal(GVar))      return; -  std::string name = Mang->getValueName(GVar); +  std::string name = Mang->getMangledName(GVar);    Constant *C = GVar->getInitializer();    if (isa<MDNode>(C) || isa<MDString>(C))      return; diff --git a/llvm/lib/Target/CBackend/CBackend.cpp b/llvm/lib/Target/CBackend/CBackend.cpp index 09ff9a2d4b6..d9c62565837 100644 --- a/llvm/lib/Target/CBackend/CBackend.cpp +++ b/llvm/lib/Target/CBackend/CBackend.cpp @@ -1432,7 +1432,7 @@ void CWriter::printConstantWithCast(Constant* CPV, unsigned Opcode) {  std::string CWriter::GetValueName(const Value *Operand) {    // Mangle globals with the standard mangler interface for LLC compatibility.    if (const GlobalValue *GV = dyn_cast<GlobalValue>(Operand)) -    return Mang->getValueName(GV); +    return Mang->getMangledName(GV);    std::string Name = Operand->getName(); diff --git a/llvm/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp b/llvm/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp index bc4facda9ff..514006cab18 100644 --- a/llvm/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp +++ b/llvm/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp @@ -347,7 +347,7 @@ void SPUAsmPrinter::printOp(const MachineOperand &MO) {    case MachineOperand::MO_GlobalAddress: {      // Computing the address of a global symbol, not calling it.      GlobalValue *GV = MO.getGlobal(); -    std::string Name = Mang->getValueName(GV); +    std::string Name = Mang->getMangledName(GV);      // External or weakly linked global variables need non-lazily-resolved      // stubs @@ -515,7 +515,7 @@ void LinuxAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {    if (EmitSpecialLLVMGlobal(GVar))      return; -  std::string name = Mang->getValueName(GVar); +  std::string name = Mang->getMangledName(GVar);    printVisibility(name, GVar->getVisibility()); diff --git a/llvm/lib/Target/DarwinTargetAsmInfo.cpp b/llvm/lib/Target/DarwinTargetAsmInfo.cpp index 0b6babe53b1..329beff3c53 100644 --- a/llvm/lib/Target/DarwinTargetAsmInfo.cpp +++ b/llvm/lib/Target/DarwinTargetAsmInfo.cpp @@ -103,18 +103,21 @@ DarwinTargetAsmInfo::DarwinTargetAsmInfo(const TargetMachine &TM)  /// emitUsedDirectiveFor - On Darwin, internally linked data beginning with  /// the PrivateGlobalPrefix or the LessPrivateGlobalPrefix does not have the  /// directive emitted (this occurs in ObjC metadata). -  bool  DarwinTargetAsmInfo::emitUsedDirectiveFor(const GlobalValue* GV,                                            Mangler *Mang) const {    if (GV==0)      return false; +   +  /// FIXME: WHAT IS THIS? +      if (GV->hasLocalLinkage() && !isa<Function>(GV) &&        ((strlen(getPrivateGlobalPrefix()) != 0 && -        Mang->getValueName(GV).substr(0,strlen(getPrivateGlobalPrefix())) == +        Mang->getMangledName(GV).substr(0,strlen(getPrivateGlobalPrefix())) ==            getPrivateGlobalPrefix()) ||         (strlen(getLessPrivateGlobalPrefix()) != 0 && -        Mang->getValueName(GV).substr(0,strlen(getLessPrivateGlobalPrefix())) == +        Mang->getMangledName(GV).substr(0, +                                        strlen(getLessPrivateGlobalPrefix())) ==            getLessPrivateGlobalPrefix())))      return false;    return true; diff --git a/llvm/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp b/llvm/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp index e7ed64e5c85..67978686b33 100644 --- a/llvm/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp +++ b/llvm/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp @@ -201,16 +201,16 @@ void IA64AsmPrinter::printOp(const MachineOperand &MO,      // Intel ias rightly complains of an 'undefined symbol')      if (F /*&& isBRCALLinsn*/ && F->isDeclaration()) -      ExternalFunctionNames.insert(Mang->getValueName(MO.getGlobal())); +      ExternalFunctionNames.insert(Mang->getMangledName(MO.getGlobal()));      else        if (GV->isDeclaration()) // e.g. stuff like 'stdin' -        ExternalObjectNames.insert(Mang->getValueName(MO.getGlobal())); +        ExternalObjectNames.insert(Mang->getMangledName(MO.getGlobal()));      if (!isBRCALLinsn)        O << "@ltoff(";      if (Needfptr)        O << "@fptr("; -    O << Mang->getValueName(MO.getGlobal()); +    O << Mang->getMangledName(MO.getGlobal());      if (Needfptr && !isBRCALLinsn)        O << "#))"; // close both fptr( and ltoff( @@ -268,7 +268,7 @@ void IA64AsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {      return;    O << "\n\n"; -  std::string name = Mang->getValueName(GVar); +  std::string name = Mang->getMangledName(GVar);    Constant *C = GVar->getInitializer();    if (isa<MDNode>(C) || isa<MDString>(C))      return; diff --git a/llvm/lib/Target/MSIL/MSILWriter.cpp b/llvm/lib/Target/MSIL/MSILWriter.cpp index 591c37107d3..1c2ea2f910e 100644 --- a/llvm/lib/Target/MSIL/MSILWriter.cpp +++ b/llvm/lib/Target/MSIL/MSILWriter.cpp @@ -242,7 +242,7 @@ bool MSILWriter::isZeroValue(const Value* V) {  std::string MSILWriter::getValueName(const Value* V) {    std::string Name;    if (const GlobalValue *GV = cast<GlobalValue>(V)) -    Name = Mang->getValueName(GV); +    Name = Mang->getMangledName(GV);    else {      unsigned &No = AnonValueNumbers[V];      if (No == 0) No = ++NextAnonValueNumber; @@ -269,7 +269,7 @@ std::string MSILWriter::getLabelName(const std::string& Name) {  std::string MSILWriter::getLabelName(const Value* V) {    std::string Name;    if (const GlobalValue *GV = cast<GlobalValue>(V)) -    Name = Mang->getValueName(GV); +    Name = Mang->getMangledName(GV);    else {      unsigned &No = AnonValueNumbers[V];      if (No == 0) No = ++NextAnonValueNumber; @@ -1630,7 +1630,7 @@ const char* MSILWriter::getLibraryName(const Function* F) {  const char* MSILWriter::getLibraryName(const GlobalVariable* GV) { -  return getLibraryForSymbol(Mang->getValueName(GV).c_str(), false, 0); +  return getLibraryForSymbol(Mang->getMangledName(GV).c_str(), false, 0);  } @@ -1688,7 +1688,7 @@ void MSILWriter::printExternals() {      std::string Tmp = getTypeName(I->getType())+getValueName(&*I);      printSimpleInstruction("ldsflda",Tmp.c_str());      Out << "\tldstr\t\"" << getLibraryName(&*I) << "\"\n"; -    Out << "\tldstr\t\"" << Mang->getValueName(&*I) << "\"\n"; +    Out << "\tldstr\t\"" << Mang->getMangledName(&*I) << "\"\n";      printSimpleInstruction("call","void* $MSIL_Import(string,string)");      printIndirectSave(I->getType());    } diff --git a/llvm/lib/Target/MSP430/MSP430AsmPrinter.cpp b/llvm/lib/Target/MSP430/MSP430AsmPrinter.cpp index b6eb6fef566..c92824a7599 100644 --- a/llvm/lib/Target/MSP430/MSP430AsmPrinter.cpp +++ b/llvm/lib/Target/MSP430/MSP430AsmPrinter.cpp @@ -185,7 +185,7 @@ void MSP430AsmPrinter::printOperand(const MachineInstr *MI, int OpNum,    case MachineOperand::MO_GlobalAddress: {      bool isMemOp  = Modifier && !strcmp(Modifier, "mem");      bool isCallOp = Modifier && !strcmp(Modifier, "call"); -    std::string Name = Mang->getValueName(MO.getGlobal()); +    std::string Name = Mang->getMangledName(MO.getGlobal());      assert(MO.getOffset() == 0 && "No offsets allowed!");      if (isCallOp) diff --git a/llvm/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp b/llvm/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp index 7a0e5e8ac33..55f3378b9f3 100644 --- a/llvm/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp +++ b/llvm/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp @@ -385,10 +385,7 @@ printOperand(const MachineInstr *MI, int opNum)        return;      case MachineOperand::MO_GlobalAddress: -      { -        const GlobalValue *GV = MO.getGlobal(); -        O << Mang->getValueName(GV); -      } +      O << Mang->getMangledName(MO.getGlobal());        break;      case MachineOperand::MO_ExternalSymbol: @@ -481,7 +478,7 @@ printModuleLevelGV(const GlobalVariable* GVar) {      return;    O << "\n\n"; -  std::string name = Mang->getValueName(GVar); +  std::string name = Mang->getMangledName(GVar);    Constant *C = GVar->getInitializer();    if (isa<MDNode>(C) || isa<MDString>(C))      return; diff --git a/llvm/lib/Target/PIC16/PIC16AsmPrinter.cpp b/llvm/lib/Target/PIC16/PIC16AsmPrinter.cpp index b6401df2878..61d295c2a23 100644 --- a/llvm/lib/Target/PIC16/PIC16AsmPrinter.cpp +++ b/llvm/lib/Target/PIC16/PIC16AsmPrinter.cpp @@ -47,7 +47,7 @@ bool PIC16AsmPrinter::runOnMachineFunction(MachineFunction &MF) {    // Get the mangled name.    const Function *F = MF.getFunction(); -  CurrentFnName = Mang->getValueName(F); +  CurrentFnName = Mang->getMangledName(F);    // Emit the function frame (args and temps).    EmitFunctionFrame(MF); @@ -136,7 +136,7 @@ void PIC16AsmPrinter::printOperand(const MachineInstr *MI, int opNum) {        return;      case MachineOperand::MO_GlobalAddress: { -      O << Mang->getValueName(MO.getGlobal()); +      O << Mang->getMangledName(MO.getGlobal());        break;      }      case MachineOperand::MO_ExternalSymbol: { @@ -222,7 +222,7 @@ void PIC16AsmPrinter::EmitFunctionDecls (Module &M) {   // Emit declarations for external functions.    O <<"\n"<<TAI->getCommentString() << "Function Declarations - BEGIN." <<"\n";    for (Module::iterator I = M.begin(), E = M.end(); I != E; I++) { -    std::string Name = Mang->getValueName(I); +    std::string Name = Mang->getMangledName(I);      if (Name.compare("@abort") == 0)        continue; @@ -252,7 +252,7 @@ void PIC16AsmPrinter::EmitUndefinedVars (Module &M)    O << "\n" << TAI->getCommentString() << "Imported Variables - BEGIN" << "\n";    for (unsigned j = 0; j < Items.size(); j++) { -    O << TAI->getExternDirective() << Mang->getValueName(Items[j]) << "\n"; +    O << TAI->getExternDirective() << Mang->getMangledName(Items[j]) << "\n";    }    O << TAI->getCommentString() << "Imported Variables - END" << "\n";  } @@ -265,7 +265,7 @@ void PIC16AsmPrinter::EmitDefinedVars (Module &M)    O << "\n" <<  TAI->getCommentString() << "Exported Variables - BEGIN" << "\n";    for (unsigned j = 0; j < Items.size(); j++) { -    O << TAI->getGlobalDirective() << Mang->getValueName(Items[j]) << "\n"; +    O << TAI->getGlobalDirective() << Mang->getMangledName(Items[j]) << "\n";    }    O <<  TAI->getCommentString() << "Exported Variables - END" << "\n";  } @@ -281,7 +281,7 @@ void PIC16AsmPrinter::EmitRomData (Module &M)      O << "\n";      SwitchToSection(PTAI->ROSections[i]->S_);      for (unsigned j = 0; j < Items.size(); j++) { -      O << Mang->getValueName(Items[j]); +      O << Mang->getMangledName(Items[j]);        Constant *C = Items[j]->getInitializer();        int AddrSpace = Items[j]->getType()->getAddressSpace();        EmitGlobalConstant(C, AddrSpace); @@ -300,7 +300,7 @@ bool PIC16AsmPrinter::doFinalization(Module &M) {  void PIC16AsmPrinter::EmitFunctionFrame(MachineFunction &MF) {    const Function *F = MF.getFunction(); -  std::string FuncName = Mang->getValueName(F); +  std::string FuncName = Mang->getMangledName(F);    const TargetData *TD = TM.getTargetData();    // Emit the data section name.    O << "\n";  @@ -354,7 +354,7 @@ void PIC16AsmPrinter::EmitIData (Module &M) {      SwitchToSection(IDATASections[i]->S_);      std::vector<const GlobalVariable*> Items = IDATASections[i]->Items;      for (unsigned j = 0; j < Items.size(); j++) { -      std::string Name = Mang->getValueName(Items[j]); +      std::string Name = Mang->getMangledName(Items[j]);        Constant *C = Items[j]->getInitializer();        int AddrSpace = Items[j]->getType()->getAddressSpace();        O << Name; @@ -373,7 +373,7 @@ void PIC16AsmPrinter::EmitUData (Module &M) {      SwitchToSection(BSSSections[i]->S_);      std::vector<const GlobalVariable*> Items = BSSSections[i]->Items;      for (unsigned j = 0; j < Items.size(); j++) { -      std::string Name = Mang->getValueName(Items[j]); +      std::string Name = Mang->getMangledName(Items[j]);        Constant *C = Items[j]->getInitializer();        const Type *Ty = C->getType();        unsigned Size = TD->getTypeAllocSize(Ty); @@ -401,7 +401,7 @@ void PIC16AsmPrinter::EmitAutos (std::string FunctName)        SwitchToSection(AutosSections[i]->S_);        std::vector<const GlobalVariable*> Items = AutosSections[i]->Items;        for (unsigned j = 0; j < Items.size(); j++) { -        std::string VarName = Mang->getValueName(Items[j]); +        std::string VarName = Mang->getMangledName(Items[j]);          Constant *C = Items[j]->getInitializer();          const Type *Ty = C->getType();          unsigned Size = TD->getTypeAllocSize(Ty); @@ -434,7 +434,7 @@ void PIC16AsmPrinter::EmitRemainingAutos()      SwitchToSection(AutosSections[i]->S_);      std::vector<const GlobalVariable*> Items = AutosSections[i]->Items;      for (unsigned j = 0; j < Items.size(); j++) { -      std::string VarName = Mang->getValueName(Items[j]); +      std::string VarName = Mang->getMangledName(Items[j]);        Constant *C = Items[j]->getInitializer();        const Type *Ty = C->getType();        unsigned Size = TD->getTypeAllocSize(Ty); diff --git a/llvm/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp index fddc1c2993f..e86c7c340e7 100644 --- a/llvm/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp +++ b/llvm/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp @@ -191,7 +191,7 @@ namespace {            GlobalValue *GV = MO.getGlobal();            if (GV->isDeclaration() || GV->isWeakForLinker()) {              // Dynamically-resolved functions need a stub for the function. -            std::string Name = Mang->getValueName(GV); +            std::string Name = Mang->getMangledName(GV);              FnStubs.insert(Name);              printSuffixedName(Name, "$stub");              return; @@ -376,7 +376,7 @@ void PPCAsmPrinter::printOp(const MachineOperand &MO) {    case MachineOperand::MO_GlobalAddress: {      // Computing the address of a global symbol, not calling it.      GlobalValue *GV = MO.getGlobal(); -    std::string Name = Mang->getValueName(GV); +    std::string Name = Mang->getMangledName(GV);      // External or weakly linked global variables need non-lazily-resolved stubs      if (TM.getRelocationModel() != Reloc::Static) { @@ -646,7 +646,7 @@ void PPCLinuxAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {    if (EmitSpecialLLVMGlobal(GVar))      return; -  std::string name = Mang->getValueName(GVar); +  std::string name = Mang->getMangledName(GVar);    printVisibility(name, GVar->getVisibility()); @@ -865,8 +865,7 @@ void PPCDarwinAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {      return;    } -  std::string name = Mang->getValueName(GVar); - +  std::string name = Mang->getMangledName(GVar);    printVisibility(name, GVar->getVisibility());    Constant *C = GVar->getInitializer(); diff --git a/llvm/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp b/llvm/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp index e01ce7259b7..024e6924e70 100644 --- a/llvm/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp +++ b/llvm/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp @@ -172,10 +172,7 @@ void SparcAsmPrinter::printOperand(const MachineInstr *MI, int opNum) {      printBasicBlockLabel(MO.getMBB());      return;    case MachineOperand::MO_GlobalAddress: -    { -      const GlobalValue *GV = MO.getGlobal(); -      O << Mang->getValueName(GV); -    } +    O << Mang->getMangledName(MO.getGlobal());      break;    case MachineOperand::MO_ExternalSymbol:      O << MO.getSymbolName(); @@ -251,7 +248,7 @@ void SparcAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {      return;    O << "\n\n"; -  std::string name = Mang->getValueName(GVar); +  std::string name = Mang->getMangledName(GVar);    Constant *C = GVar->getInitializer();    if (isa<MDNode>(C) || isa<MDString>(C))      return; diff --git a/llvm/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp b/llvm/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp index c726ccc57e8..a567a8ff330 100644 --- a/llvm/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp +++ b/llvm/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp @@ -233,7 +233,7 @@ bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) {    EmitConstantPool(MF.getConstantPool());    if (F->hasDLLExportLinkage()) -    DLLExportedFns.insert(Mang->getValueName(F)); +    DLLExportedFns.insert(Mang->getMangledName(F));    // Print the 'header' of function    emitFunctionHeader(MF); @@ -304,62 +304,58 @@ void X86ATTAsmPrinter::printSymbolOperand(const MachineOperand &MO) {      break;    case MachineOperand::MO_GlobalAddress: {      const GlobalValue *GV = MO.getGlobal(); -    std::string Name = Mang->getValueName(GV); -    decorateName(Name, GV); -    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; -    } +    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'); +    decorateName(Name, GV);      // 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); -      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); -      printSuffixedName(Name, "$non_lazy_ptr"); -    } else if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) { -      FnStubs.insert(Name); -      printSuffixedName(Name, "$stub"); -    } else { -      O << Name; -    } +    if (MO.getTargetFlags() == X86II::MO_DLLIMPORT) +      Name = "__imp_" + Name; -    if (needCloseParen) -      O << ')'; +    if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY || +        MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE) +      GVStubs[Name] = Mang->getMangledName(GV); +    else if (MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY || +             MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE) +      HiddenGVStubs[Name] = Mang->getMangledName(GV); +    else if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) +      FnStubs[Name] = Mang->getMangledName(GV); +     +    // 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;      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) { -      FnStubs.insert(Name); -      printSuffixedName(Name, "$stub"); -    } else { -      O << Name; +      FnStubs[Name+"$stub"] = Name; +      Name += "$stub";      } -    if (needCloseParen) -      O << ')'; +    // 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;      break;    }    } @@ -787,7 +783,7 @@ void X86ATTAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {      return;    } -  std::string name = Mang->getValueName(GVar); +  std::string name = Mang->getMangledName(GVar);    Constant *C = GVar->getInitializer();    if (isa<MDNode>(C) || isa<MDString>(C))      return; @@ -910,7 +906,7 @@ bool X86ATTAsmPrinter::doFinalization(Module &M) {      printModuleLevelGV(I);      if (I->hasDLLExportLinkage()) -      DLLExportedGVs.insert(Mang->getValueName(I)); +      DLLExportedGVs.insert(Mang->getMangledName(I));    }    if (Subtarget->isTargetDarwin()) { @@ -921,26 +917,21 @@ bool X86ATTAsmPrinter::doFinalization(Module &M) {      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] == 0) -          continue; -        std::string Name = Mang->getValueName(Personalities[i]); -        decorateName(Name, Personalities[i]); -        GVStubs.insert(Name); +        if (Personalities[i]) +          GVStubs[Mang->getMangledName(Personalities[i], "$non_lazy_ptr", +                                       true /*private label*/)] =  +            Mang->getMangledName(Personalities[i]);        }      }      // Output stubs for dynamically-linked functions      if (!FnStubs.empty()) { -      for (StringSet<>::iterator I = FnStubs.begin(), E = FnStubs.end(); -           I != E; ++I) { -        SwitchToDataSection("\t.section __IMPORT,__jump_table,symbol_stubs," -                            "self_modifying_code+pure_instructions,5", 0); -        const char *Name = I->getKeyData(); -        printSuffixedName(Name, "$stub"); -        O << ":\n" -             "\t.indirect_symbol " << Name << "\n" -             "\thlt ; hlt ; hlt ; hlt ; hlt\n"; -      } +      SwitchToDataSection("\t.section __IMPORT,__jump_table,symbol_stubs," +                          "self_modifying_code+pure_instructions,5", 0); +      for (StringMap<std::string>::iterator I = FnStubs.begin(), +           E = FnStubs.end(); I != E; ++I) +        O << I->getKeyData() << ":\n" << "\t.indirect_symbol " << I->second +          << "\n\thlt ; hlt ; hlt ; hlt ; hlt\n";        O << '\n';      } @@ -948,23 +939,19 @@ bool X86ATTAsmPrinter::doFinalization(Module &M) {      if (!GVStubs.empty()) {        SwitchToDataSection(                      "\t.section __IMPORT,__pointers,non_lazy_symbol_pointers"); -      for (StringSet<>::iterator I = GVStubs.begin(), E = GVStubs.end(); -           I != E; ++I) { -        const char *Name = I->getKeyData(); -        printSuffixedName(Name, "$non_lazy_ptr"); -        O << ":\n\t.indirect_symbol " << Name << "\n\t.long\t0\n"; -      } +      for (StringMap<std::string>::iterator I = GVStubs.begin(), +           E = GVStubs.end(); I != E; ++I) +        O << I->getKeyData() << ":\n\t.indirect_symbol " +          << I->second << "\n\t.long\t0\n";      }      if (!HiddenGVStubs.empty()) {        SwitchToSection(TAI->getDataSection());        EmitAlignment(2); -      for (StringSet<>::iterator I = HiddenGVStubs.begin(), -           E = HiddenGVStubs.end(); I != E; ++I) { -        const char *Name = I->getKeyData(); -        printSuffixedName(Name, "$non_lazy_ptr"); -        O << ":\n" << TAI->getData32bitsDirective() << Name << '\n'; -      } +      for (StringMap<std::string>::iterator I = HiddenGVStubs.begin(), +           E = HiddenGVStubs.end(); I != E; ++I) +        O << I->getKeyData() << ":\n" << TAI->getData32bitsDirective() +          << I->second << '\n';      }      // Funny Darwin hack: This flag tells the linker that no global symbols diff --git a/llvm/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h b/llvm/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h index 8ca36d73c24..2ab63dcb28d 100644 --- a/llvm/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h +++ b/llvm/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h @@ -200,10 +200,10 @@ class VISIBILITY_HIDDEN X86ATTAsmPrinter : public AsmPrinter {    void emitFunctionHeader(const MachineFunction &MF);    // Necessary for Darwin to print out the apprioriate types of linker stubs -  StringSet<> FnStubs, GVStubs, HiddenGVStubs, CygMingStubs; +  StringMap<std::string> FnStubs, GVStubs, HiddenGVStubs;    // Necessary for dllexport support -  StringSet<> DLLExportedFns, DLLExportedGVs; +  StringSet<> CygMingStubs, DLLExportedFns, DLLExportedGVs;    // We have to propagate some information about MachineFunction to    // AsmPrinter. It's ok, when we're printing the function, since we have diff --git a/llvm/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp b/llvm/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp index 9890fddbecf..4b888416423 100644 --- a/llvm/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp +++ b/llvm/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp @@ -240,8 +240,7 @@ void X86IntelAsmPrinter::printOp(const MachineOperand &MO,    case MachineOperand::MO_GlobalAddress: {      bool isMemOp  = Modifier && !strcmp(Modifier, "mem");      GlobalValue *GV = MO.getGlobal(); -    std::string Name = Mang->getValueName(GV); - +    std::string Name = Mang->getMangledName(GV);      decorateName(Name, GV);      if (!isMemOp) O << "OFFSET "; @@ -278,7 +277,7 @@ void X86IntelAsmPrinter::print_pcrel_imm(const MachineInstr *MI, unsigned OpNo){    case MachineOperand::MO_GlobalAddress: {      GlobalValue *GV = MO.getGlobal(); -    std::string Name = Mang->getValueName(GV); +    std::string Name = Mang->getMangledName(GV);      decorateName(Name, GV);      // Handle dllimport linkage. @@ -446,7 +445,7 @@ bool X86IntelAsmPrinter::doInitialization(Module &M) {    // Emit declarations for external functions.    for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)      if (I->isDeclaration()) { -      std::string Name = Mang->getValueName(I); +      std::string Name = Mang->getMangledName(I);        decorateName(Name, I);        O << "\tEXTERN " ; @@ -461,7 +460,7 @@ bool X86IntelAsmPrinter::doInitialization(Module &M) {    for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();         I != E; ++I) {      if (I->isDeclaration()) { -      std::string Name = Mang->getValueName(I); +      std::string Name = Mang->getMangledName(I);        O << "\tEXTERN " ;        if (I->hasDLLImportLinkage()) { @@ -486,7 +485,7 @@ bool X86IntelAsmPrinter::doFinalization(Module &M) {      if (EmitSpecialLLVMGlobal(I))        continue; -    std::string name = Mang->getValueName(I); +    std::string name = Mang->getMangledName(I);      Constant *C = I->getInitializer();      unsigned Align = TD->getPreferredAlignmentLog(I);      bool bCustomSegment = false; diff --git a/llvm/lib/Target/XCore/XCoreAsmPrinter.cpp b/llvm/lib/Target/XCore/XCoreAsmPrinter.cpp index 5874294886e..5beefe6ea62 100644 --- a/llvm/lib/Target/XCore/XCoreAsmPrinter.cpp +++ b/llvm/lib/Target/XCore/XCoreAsmPrinter.cpp @@ -178,7 +178,7 @@ emitGlobal(const GlobalVariable *GV)      SwitchToSection(TAI->SectionForGlobal(GV)); -    std::string name = Mang->getValueName(GV); +    std::string name = Mang->getMangledName(GV);      Constant *C = GV->getInitializer();      unsigned Align = (unsigned)TD->getPreferredTypeAlignmentShift(C->getType()); @@ -367,7 +367,7 @@ void XCoreAsmPrinter::printOperand(const MachineInstr *MI, int opNum) {      printBasicBlockLabel(MO.getMBB());      break;    case MachineOperand::MO_GlobalAddress: -    O << Mang->getValueName(MO.getGlobal()); +    O << Mang->getMangledName(MO.getGlobal());      break;    case MachineOperand::MO_ExternalSymbol:      O << MO.getSymbolName(); diff --git a/llvm/lib/VMCore/Mangler.cpp b/llvm/lib/VMCore/Mangler.cpp index cec41dfd400..84c4396fdc2 100644 --- a/llvm/lib/VMCore/Mangler.cpp +++ b/llvm/lib/VMCore/Mangler.cpp @@ -39,9 +39,6 @@ std::string Mangler::makeNameProper(const std::string &X,    if (PreserveAsmNames && X[0] == 1)      return X; -  // Figure out the prefix to use. -  const char *ThePrefix = hasPrivateLinkage ? PrivatePrefix : Prefix; -      if (!UseQuotes) {      std::string Result; @@ -64,8 +61,11 @@ std::string Mangler::makeNameProper(const std::string &X,          Result += *I;      } -    if (NeedPrefix) -      Result = ThePrefix + Result; +    if (NeedPrefix) { +      Result = Prefix + Result; +      if (hasPrivateLinkage) +        Result = PrivatePrefix + Result; +    }      return Result;    } @@ -95,7 +95,11 @@ std::string Mangler::makeNameProper(const std::string &X,    if (!NeedQuotes) {      if (!NeedPrefix)        return X.substr(1);   // Strip off the \001. -    return ThePrefix + X; +     +    Result = Prefix + X; +    if (hasPrivateLinkage) +      Result = PrivatePrefix + Result; +    return Result;    }    Result = X.substr(0, I-X.begin()); @@ -110,18 +114,28 @@ std::string Mangler::makeNameProper(const std::string &X,        Result += *I;    } -  if (NeedPrefix) -    Result = ThePrefix + Result; +  if (NeedPrefix) { +    Result = Prefix + Result; +    if (hasPrivateLinkage) +      Result = PrivatePrefix + Result; +  }    Result = '"' + Result + '"';    return Result;  } -std::string Mangler::getValueName(const GlobalValue *GV, const char *Suffix) { +/// 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) {    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()); +    return makeNameProper(GV->getName() + Suffix, +                          GV->hasPrivateLinkage() | ForcePrivate);    // Get the ID for the global, assigning a new one if we haven't got one    // already. @@ -129,7 +143,8 @@ std::string Mangler::getValueName(const GlobalValue *GV, const char *Suffix) {    if (ID == 0) ID = NextAnonGlobalID++;    // Must mangle the global into a unique ID. -  return "__unnamed_" + utostr(ID) + Suffix; +  return makeNameProper("__unnamed_" + utostr(ID) + Suffix, +                        GV->hasPrivateLinkage() | ForcePrivate);  }  Mangler::Mangler(Module &M, const char *prefix, const char *privatePrefix) diff --git a/llvm/test/CodeGen/PowerPC/private.ll b/llvm/test/CodeGen/PowerPC/private.ll index a36adf58a8c..30cf938e63b 100644 --- a/llvm/test/CodeGen/PowerPC/private.ll +++ b/llvm/test/CodeGen/PowerPC/private.ll @@ -6,12 +6,10 @@  ; RUN: grep .Lbaz: %t  ; RUN: grep lis.*\.Lbaz %t  ; RUN: llvm-as < %s | llc -mtriple=powerpc-apple-darwin > %t -; RUN: grep Lfoo: %t -; RUN: grep bl.*\Lfoo %t -; RUN: grep Lbaz: %t -; RUN: grep lis.*\Lbaz %t - -declare void @foo() nounwind +; RUN: grep L_foo: %t +; RUN: grep bl.*\L_foo %t +; RUN: grep L_baz: %t +; RUN: grep lis.*\L_baz %t  define private void @foo() nounwind {          ret void diff --git a/llvm/test/CodeGen/X86/private-2.ll b/llvm/test/CodeGen/X86/private-2.ll index 689fe34bab1..74781285677 100644 --- a/llvm/test/CodeGen/X86/private-2.ll +++ b/llvm/test/CodeGen/X86/private-2.ll @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -mtriple=x86_64-apple-darwin10 | grep L_ZZ20 +; RUN: llvm-as < %s | llc -mtriple=x86_64-apple-darwin10 | grep L__ZZ20  ; Quote should be outside of private prefix.  ; rdar://6855766x diff --git a/llvm/tools/bugpoint/Miscompilation.cpp b/llvm/tools/bugpoint/Miscompilation.cpp index 5fffcc19dbb..a3a1e29b9fc 100644 --- a/llvm/tools/bugpoint/Miscompilation.cpp +++ b/llvm/tools/bugpoint/Miscompilation.cpp @@ -244,9 +244,9 @@ static void DisambiguateGlobalSymbols(Module *M) {    Mang.setPreserveAsmNames(true);    for (Module::global_iterator I = M->global_begin(), E = M->global_end();         I != E; ++I) -    I->setName(Mang.getValueName(I)); +    I->setName(Mang.getMangledName(I));    for (Module::iterator  I = M->begin(),  E = M->end();  I != E; ++I) -    I->setName(Mang.getValueName(I)); +    I->setName(Mang.getMangledName(I));  }  /// ExtractLoops - Given a reduced list of functions that still exposed the bug, diff --git a/llvm/tools/lto/LTOCodeGenerator.cpp b/llvm/tools/lto/LTOCodeGenerator.cpp index 801707f8d98..26effa55277 100644 --- a/llvm/tools/lto/LTOCodeGenerator.cpp +++ b/llvm/tools/lto/LTOCodeGenerator.cpp @@ -371,13 +371,13 @@ void LTOCodeGenerator::applyScopeRestrictions()              for (Module::iterator f = mergedModule->begin(),                                           e = mergedModule->end(); f != e; ++f) {                  if ( !f->isDeclaration()  -                  && _mustPreserveSymbols.count(mangler.getValueName(f)) ) +                  && _mustPreserveSymbols.count(mangler.getMangledName(f)) )                      mustPreserveList.push_back(::strdup(f->getName().c_str()));              }              for (Module::global_iterator v = mergedModule->global_begin(),                                    e = mergedModule->global_end(); v !=  e; ++v) {                  if ( !v->isDeclaration() -                  && _mustPreserveSymbols.count(mangler.getValueName(v)) ) +                  && _mustPreserveSymbols.count(mangler.getMangledName(v)) )                      mustPreserveList.push_back(::strdup(v->getName().c_str()));              }              passes.add(createInternalizePass(mustPreserveList)); diff --git a/llvm/tools/lto/LTOModule.cpp b/llvm/tools/lto/LTOModule.cpp index c4980d6bf79..38ee1cc7a28 100644 --- a/llvm/tools/lto/LTOModule.cpp +++ b/llvm/tools/lto/LTOModule.cpp @@ -332,7 +332,7 @@ void LTOModule::addDefinedSymbol(GlobalValue* def, Mangler &mangler,          return;      // string is owned by _defines -    const char* symbolName = ::strdup(mangler.getValueName(def).c_str()); +    const char* symbolName = ::strdup(mangler.getMangledName(def).c_str());      // set alignment part log2() can have rounding errors      uint32_t align = def->getAlignment(); @@ -405,7 +405,7 @@ void LTOModule::addPotentialUndefinedSymbol(GlobalValue* decl, Mangler &mangler)      if (isa<GlobalAlias>(decl))          return; -    const char* name = mangler.getValueName(decl).c_str(); +    const char* name = mangler.getMangledName(decl).c_str();      // we already have the symbol      if (_undefines.find(name) != _undefines.end())  | 

