Use the mangler consistently instead of using getGlobalPrefix directly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195911 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2013-11-28 08:59:52 +00:00
parent 680cd7b077
commit 60f6083a36
5 changed files with 17 additions and 19 deletions

View File

@ -25,6 +25,7 @@
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/MutexGuard.h" #include "llvm/Support/MutexGuard.h"
#include "llvm/Target/Mangler.h"
using namespace llvm; using namespace llvm;
@ -231,11 +232,10 @@ void *MCJIT::getPointerToBasicBlock(BasicBlock *BB) {
} }
uint64_t MCJIT::getExistingSymbolAddress(const std::string &Name) { uint64_t MCJIT::getExistingSymbolAddress(const std::string &Name) {
// Check with the RuntimeDyld to see if we already have this symbol. Mangler Mang(TM);
if (Name[0] == '\1') SmallString<128> FullName;
return Dyld.getSymbolLoadAddress(Name.substr(1)); Mang.getNameWithPrefix(FullName, Name);
return Dyld.getSymbolLoadAddress((TM->getMCAsmInfo()->getGlobalPrefix() return Dyld.getSymbolLoadAddress(FullName);
+ Name));
} }
Module *MCJIT::findModuleForSymbol(const std::string &Name, Module *MCJIT::findModuleForSymbol(const std::string &Name,
@ -320,15 +320,13 @@ void *MCJIT::getPointerToFunction(Function *F) {
return NULL; return NULL;
// FIXME: Should the Dyld be retaining module information? Probably not. // FIXME: Should the Dyld be retaining module information? Probably not.
// FIXME: Should we be using the mangler for this? Probably.
// //
// This is the accessor for the target address, so make sure to check the // This is the accessor for the target address, so make sure to check the
// load address of the symbol, not the local address. // load address of the symbol, not the local address.
StringRef BaseName = F->getName(); Mangler Mang(TM);
if (BaseName[0] == '\1') SmallString<128> Name;
return (void*)Dyld.getSymbolLoadAddress(BaseName.substr(1)); Mang.getNameWithPrefix(Name, F, false);
return (void*)Dyld.getSymbolLoadAddress((TM->getMCAsmInfo()->getGlobalPrefix() return (void*)Dyld.getSymbolLoadAddress(Name);
+ BaseName).str());
} }
void *MCJIT::recompileAndRelinkFunction(Function *F) { void *MCJIT::recompileAndRelinkFunction(Function *F) {

View File

@ -102,7 +102,9 @@ void MSP430AsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
case MachineOperand::MO_ExternalSymbol: { case MachineOperand::MO_ExternalSymbol: {
bool isMemOp = Modifier && !strcmp(Modifier, "mem"); bool isMemOp = Modifier && !strcmp(Modifier, "mem");
O << (isMemOp ? '&' : '#'); O << (isMemOp ? '&' : '#');
O << MAI->getGlobalPrefix() << MO.getSymbolName(); SmallString<128> Name;
Mang->getNameWithPrefix(Name, MO.getSymbolName());
O << Name;
return; return;
} }
} }

View File

@ -176,9 +176,9 @@ void PPCAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
return; return;
} }
MCSymbol *NLPSym = SmallString<128> Name;
OutContext.GetOrCreateSymbol(StringRef(MAI->getGlobalPrefix())+ Mang->getNameWithPrefix(Name, Twine(MO.getSymbolName()) + "$non_lazy_ptr");
MO.getSymbolName()+"$non_lazy_ptr"); MCSymbol *NLPSym = OutContext.GetOrCreateSymbol(Name);
MachineModuleInfoImpl::StubValueTy &StubSym = MachineModuleInfoImpl::StubValueTy &StubSym =
MMI->getObjFileInfo<MachineModuleInfoMachO>().getGVStubEntry(NLPSym); MMI->getObjFileInfo<MachineModuleInfoMachO>().getGVStubEntry(NLPSym);
if (StubSym.getPointer() == 0) if (StubSym.getPointer() == 0)

View File

@ -37,8 +37,7 @@ static MCSymbol *GetSymbolFromOperand(const MachineOperand &MO, AsmPrinter &AP){
SmallString<128> Name; SmallString<128> Name;
if (!MO.isGlobal()) { if (!MO.isGlobal()) {
assert(MO.isSymbol() && "Isn't a symbol reference"); assert(MO.isSymbol() && "Isn't a symbol reference");
Name += AP.MAI->getGlobalPrefix(); AP.Mang->getNameWithPrefix(Name, MO.getSymbolName());
Name += MO.getSymbolName();
} else { } else {
const GlobalValue *GV = MO.getGlobal(); const GlobalValue *GV = MO.getGlobal();
bool isImplicitlyPrivate = false; bool isImplicitlyPrivate = false;

View File

@ -85,8 +85,7 @@ GetSymbolFromOperand(const MachineOperand &MO) const {
getMang()->getNameWithPrefix(Name, GV, isImplicitlyPrivate); getMang()->getNameWithPrefix(Name, GV, isImplicitlyPrivate);
} else if (MO.isSymbol()) { } else if (MO.isSymbol()) {
Name += MAI.getGlobalPrefix(); getMang()->getNameWithPrefix(Name, MO.getSymbolName());
Name += MO.getSymbolName();
} else if (MO.isMBB()) { } else if (MO.isMBB()) {
Name += MO.getMBB()->getSymbol()->getName(); Name += MO.getMBB()->getSymbol()->getName();
} }