mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-12 13:30:51 +00:00
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
This commit is contained in:
parent
95cf30c444
commit
b8158acc23
@ -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_",
|
||||
|
@ -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)) {
|
||||
|
@ -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;
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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());
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
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);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// 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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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));
|
||||
|
@ -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())
|
||||
|
Loading…
Reference in New Issue
Block a user