Reapply my previous asmprinter changes now with more testing and two
authorChris Lattner <sabre@nondot.org>
Tue, 14 Jul 2009 18:17:16 +0000 (18:17 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 14 Jul 2009 18:17:16 +0000 (18:17 +0000)
additional bug fixes:

1. The bug that everyone hit was a problem in the asmprinter where it
   would remove $stub but keep the L prefix on a name when emitting the
   indirect symbol.  This is easy to fix by keeping the name of the stub
   and the name of the symbol in a StringMap instead of just keeping a
   StringSet and trying to reconstruct it late.

2. There was a problem printing the personality function.  The current
   logic to print out the personality function from the DWARF information
   is a bit of a cesspool right now that duplicates a bunch of other
   logic in the asm printer.  The short version of it is that it depends
   on emitting both the L and _ prefix for symbols (at least on darwin)
   and until I can untangle it, it is best to switch the mangler back to
   emitting both prefixes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75646 91177308-0d34-0410-b5e6-96231b3b80d8

27 files changed:
include/llvm/Support/Mangler.h
lib/CodeGen/AsmPrinter/AsmPrinter.cpp
lib/CodeGen/ELFWriter.cpp
lib/CodeGen/MachOCodeEmitter.cpp
lib/CodeGen/MachOWriter.cpp
lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp
lib/Target/CBackend/CBackend.cpp
lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp
lib/Target/DarwinTargetAsmInfo.cpp
lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp
lib/Target/MSIL/MSILWriter.cpp
lib/Target/MSP430/MSP430AsmPrinter.cpp
lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp
lib/Target/PIC16/PIC16AsmPrinter.cpp
lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp
lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h
lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp
lib/Target/XCore/XCoreAsmPrinter.cpp
lib/VMCore/Mangler.cpp
test/CodeGen/PowerPC/private.ll
test/CodeGen/X86/private-2.ll
tools/bugpoint/Miscompilation.cpp
tools/lto/LTOCodeGenerator.cpp
tools/lto/LTOModule.cpp

index 0dc26edc2df78c57220b35d59a61cbf49b5c671a..0578f8f2b47a828b271d33525bbc9d44016f0b73 100644 (file)
@@ -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_",
index d0b0aab0a8ee55509ebf69af1d4ca5c594f2f2d8..7e1d413fd1eaf1d2244ef799bfdee277ca8a3a8b 100644 (file)
@@ -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)) {
index e041bd34eee98d26012983541fac43a3dbcbafdf..05b736147c46cef0d3394aff142677efa431d2c1 100644 (file)
@@ -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;
index 14ebc3ff59fc986b124253f4142c75c3c4954322..77092769a943d3e7a1cdda3e059f20fcf6dd4b85 100644 (file)
@@ -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.
index 5cbe6fd5c93a7ff11053ac366b40905c8c3db3a5..d19b218b2f39f552b02100bb7a9372e134043c8d 100644 (file)
@@ -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;
     }
index f878a768f691ce9de76cc48b14ac067f44a78722..331d7aba058581155c43a43d05097088dd45d3e0 100644 (file)
@@ -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;
index 1e3e83c841088ea31ff6ce6903f729dd82060589..f43a3941230748862cba04cd1800182ea4568018 100644 (file)
@@ -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;
index 09ff9a2d4b69cead670e83c1344e1e57621bad55..d9c625658379e8579d59e59637658db0c87dea4a 100644 (file)
@@ -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();
     
index bc4facda9ffcdf8f0e31ae929d914cc036bf94dc..514006cab18e73e5b4ec548eca0b06c29dce63bd 100644 (file)
@@ -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());
 
index 0b6babe53b13e859e88ca5856462946e2cc609a6..329beff3c53b0ad4826757eec3c225ba1f039b92 100644 (file)
@@ -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;
index e7ed64e5c85ebfd439b60181e305c04a4d8a0dd9..67978686b33517dd492609fa09b86938ec6fbe77 100644 (file)
@@ -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;
index 591c37107d357f288600cedde7632df768e72cd0..1c2ea2f910e97294dd929c912bfa81f808696c03 100644 (file)
@@ -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());
   }
index b6eb6fef566e2836497589308dda08f15bc042b7..c92824a759969a87be77e745247771b189e8f9e8 100644 (file)
@@ -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)
index 7a0e5e8ac33560a87e337b093b2387388de97602..55f3378b9f386484e8ffde66af990f7d4c869eda 100644 (file)
@@ -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;
index b6401df2878f9c8b04f401f3b02a7a9d1a8eca74..61d295c2a23c3166f7447c96353c419c97da8c14 100644 (file)
@@ -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);
index fddc1c2993ff659fbc7e71f4b0ef9571d4bb312a..e86c7c340e7b04122c55f60ed629464624142b01 100644 (file)
@@ -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();
index e01ce7259b7d1df1f8591dba16bf4f3b50049c74..024e6924e70490e930c3b91929695bb09a8433ee 100644 (file)
@@ -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;
index c726ccc57e8047a0f63bd722ebd0384c8161f0ad..a567a8ff330ee5ca770c114efffd9ec28b0e5882 100644 (file)
@@ -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
index 8ca36d73c2479c5d7b5d637cbf9182277af2808d..2ab63dcb28d7996fc57329ad000ef271f823c5bd 100644 (file)
@@ -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
index 9890fddbecf1e6c7746e395246a7932477ec40ac..4b888416423770fe17cc94f4266bb89a7ca1e266 100644 (file)
@@ -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;
index 5874294886e8acec7cf7a6e40ba9e412ae72ad48..5beefe6ea62e2e7cf8e69a33d906cd428c33cc83 100644 (file)
@@ -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();
index cec41dfd40071d8a4e1572f9c6fd6e690ad579cd..84c4396fdc2ffda64799295afddd3f6cac5f7d5c 100644 (file)
@@ -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)
index a36adf58a8c549b61adfbec5d44c24500512c5a6..30cf938e63b59561911cfd6126896cbf1750ce02 100644 (file)
@@ -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
index 689fe34bab12b6f59fee3cb0006bc878fbdf58d4..7478128567730ceaa19fa29702f6b392c0cbe704 100644 (file)
@@ -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
 
index 5fffcc19dbb023607e5f05f8fba7b4df947683d2..a3a1e29b9fc737300420874394509cc1166292a3 100644 (file)
@@ -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,
index 801707f8d9801a7fd1bd118251a86840eb46b1ca..26effa55277e48bd730482193b12adc3f35da6a8 100644 (file)
@@ -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));
index c4980d6bf79bee615978cc390921ae007875ba9f..38ee1cc7a284230a0ff813dc0d02429ff343cafa 100644 (file)
@@ -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())