aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-07-14 18:17:16 +0000
committerChris Lattner <sabre@nondot.org>2009-07-14 18:17:16 +0000
commitb8158acc23f5f0bf235fb1c6a8182a38ec9b00b2 (patch)
tree83b8562d6775f42cf93a08cf76d96a5107b67747
parent95cf30c444707634bbd950f13405b6c8bcfe496b (diff)
Reapply my previous asmprinter changes now with more testing and two
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
-rw-r--r--include/llvm/Support/Mangler.h9
-rw-r--r--lib/CodeGen/AsmPrinter/AsmPrinter.cpp22
-rw-r--r--lib/CodeGen/ELFWriter.cpp2
-rw-r--r--lib/CodeGen/MachOCodeEmitter.cpp2
-rw-r--r--lib/CodeGen/MachOWriter.cpp6
-rw-r--r--lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp12
-rw-r--r--lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp8
-rw-r--r--lib/Target/CBackend/CBackend.cpp2
-rw-r--r--lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp4
-rw-r--r--lib/Target/DarwinTargetAsmInfo.cpp9
-rw-r--r--lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp8
-rw-r--r--lib/Target/MSIL/MSILWriter.cpp8
-rw-r--r--lib/Target/MSP430/MSP430AsmPrinter.cpp2
-rw-r--r--lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp7
-rw-r--r--lib/Target/PIC16/PIC16AsmPrinter.cpp22
-rw-r--r--lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp9
-rw-r--r--lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp7
-rw-r--r--lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp131
-rw-r--r--lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h4
-rw-r--r--lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp11
-rw-r--r--lib/Target/XCore/XCoreAsmPrinter.cpp4
-rw-r--r--lib/VMCore/Mangler.cpp37
-rw-r--r--test/CodeGen/PowerPC/private.ll10
-rw-r--r--test/CodeGen/X86/private-2.ll2
-rw-r--r--tools/bugpoint/Miscompilation.cpp4
-rw-r--r--tools/lto/LTOCodeGenerator.cpp4
-rw-r--r--tools/lto/LTOModule.cpp4
27 files changed, 174 insertions, 176 deletions
diff --git a/include/llvm/Support/Mangler.h b/include/llvm/Support/Mangler.h
index 0dc26edc2d..0578f8f2b4 100644
--- a/include/llvm/Support/Mangler.h
+++ b/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/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index d0b0aab0a8..7e1d413fd1 100644
--- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/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/lib/CodeGen/ELFWriter.cpp b/lib/CodeGen/ELFWriter.cpp
index e041bd34ee..05b736147c 100644
--- a/lib/CodeGen/ELFWriter.cpp
+++ b/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/lib/CodeGen/MachOCodeEmitter.cpp b/lib/CodeGen/MachOCodeEmitter.cpp
index 14ebc3ff59..77092769a9 100644
--- a/lib/CodeGen/MachOCodeEmitter.cpp
+++ b/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/lib/CodeGen/MachOWriter.cpp b/lib/CodeGen/MachOWriter.cpp
index 5cbe6fd5c9..d19b218b2f 100644
--- a/lib/CodeGen/MachOWriter.cpp
+++ b/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/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
index f878a768f6..331d7aba05 100644
--- a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
+++ b/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/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp b/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp
index 1e3e83c841..f43a394123 100644
--- a/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp
+++ b/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/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp
index 09ff9a2d4b..d9c6256583 100644
--- a/lib/Target/CBackend/CBackend.cpp
+++ b/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/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp b/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp
index bc4facda9f..514006cab1 100644
--- a/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp
+++ b/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/lib/Target/DarwinTargetAsmInfo.cpp b/lib/Target/DarwinTargetAsmInfo.cpp
index 0b6babe53b..329beff3c5 100644
--- a/lib/Target/DarwinTargetAsmInfo.cpp
+++ b/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/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp b/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp
index e7ed64e5c8..67978686b3 100644
--- a/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp
+++ b/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/lib/Target/MSIL/MSILWriter.cpp b/lib/Target/MSIL/MSILWriter.cpp
index 591c37107d..1c2ea2f910 100644
--- a/lib/Target/MSIL/MSILWriter.cpp
+++ b/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/lib/Target/MSP430/MSP430AsmPrinter.cpp b/lib/Target/MSP430/MSP430AsmPrinter.cpp
index b6eb6fef56..c92824a759 100644
--- a/lib/Target/MSP430/MSP430AsmPrinter.cpp
+++ b/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/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp b/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp
index 7a0e5e8ac3..55f3378b9f 100644
--- a/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp
+++ b/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/lib/Target/PIC16/PIC16AsmPrinter.cpp b/lib/Target/PIC16/PIC16AsmPrinter.cpp
index b6401df287..61d295c2a2 100644
--- a/lib/Target/PIC16/PIC16AsmPrinter.cpp
+++ b/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/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
index fddc1c2993..e86c7c340e 100644
--- a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
+++ b/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/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp b/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp
index e01ce7259b..024e6924e7 100644
--- a/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp
+++ b/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/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
index c726ccc57e..a567a8ff33 100644
--- a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
+++ b/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.getTar