mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-03 00:20:40 +03:00
Rename DtoMangled... to getIRMangled...
This commit is contained in:
parent
192649326d
commit
c251170912
12 changed files with 72 additions and 72 deletions
|
@ -522,16 +522,16 @@ void DtoDeclareFunction(FuncDeclaration *fdecl) {
|
||||||
const auto link = forceC ? LINKc : f->linkage;
|
const auto link = forceC ? LINKc : f->linkage;
|
||||||
|
|
||||||
// mangled name
|
// mangled name
|
||||||
const auto llMangle = DtoMangledName(fdecl, link);
|
const auto irMangle = getIRMangledName(fdecl, link);
|
||||||
|
|
||||||
// construct function
|
// construct function
|
||||||
LLFunctionType *functype = DtoFunctionType(fdecl);
|
LLFunctionType *functype = DtoFunctionType(fdecl);
|
||||||
LLFunction *func = vafunc ? vafunc : gIR->module.getFunction(llMangle);
|
LLFunction *func = vafunc ? vafunc : gIR->module.getFunction(irMangle);
|
||||||
if (!func) {
|
if (!func) {
|
||||||
// All function declarations are "external" - any other linkage type
|
// All function declarations are "external" - any other linkage type
|
||||||
// is set when actually defining the function.
|
// is set when actually defining the function.
|
||||||
func = LLFunction::Create(functype, llvm::GlobalValue::ExternalLinkage,
|
func = LLFunction::Create(functype, llvm::GlobalValue::ExternalLinkage,
|
||||||
llMangle, &gIR->module);
|
irMangle, &gIR->module);
|
||||||
} else if (func->getFunctionType() != functype) {
|
} else if (func->getFunctionType() != functype) {
|
||||||
error(fdecl->loc,
|
error(fdecl->loc,
|
||||||
"Function type does not match previously declared "
|
"Function type does not match previously declared "
|
||||||
|
|
|
@ -834,7 +834,7 @@ void DtoResolveVariable(VarDeclaration *vd) {
|
||||||
if (gIR->dmodule) {
|
if (gIR->dmodule) {
|
||||||
vd->ir->setInitialized();
|
vd->ir->setInitialized();
|
||||||
}
|
}
|
||||||
const auto llMangle = DtoMangledName(vd);
|
const auto irMangle = getIRMangledName(vd);
|
||||||
|
|
||||||
// Since the type of a global must exactly match the type of its
|
// Since the type of a global must exactly match the type of its
|
||||||
// initializer, we cannot know the type until after we have emitted the
|
// initializer, we cannot know the type until after we have emitted the
|
||||||
|
@ -855,7 +855,7 @@ void DtoResolveVariable(VarDeclaration *vd) {
|
||||||
|
|
||||||
llvm::GlobalVariable *gvar =
|
llvm::GlobalVariable *gvar =
|
||||||
getOrCreateGlobal(vd->loc, gIR->module, DtoMemType(vd->type), isLLConst,
|
getOrCreateGlobal(vd->loc, gIR->module, DtoMemType(vd->type), isLLConst,
|
||||||
linkage, nullptr, llMangle, vd->isThreadlocal());
|
linkage, nullptr, irMangle, vd->isThreadlocal());
|
||||||
getIrGlobal(vd)->value = gvar;
|
getIrGlobal(vd)->value = gvar;
|
||||||
|
|
||||||
// Set the alignment (it is important not to use type->alignsize because
|
// Set the alignment (it is important not to use type->alignsize because
|
||||||
|
|
|
@ -97,7 +97,7 @@ std::string hashSymbolName(llvm::StringRef name, Dsymbol *symb) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DtoMangledName(FuncDeclaration *fdecl, LINK link) {
|
std::string getIRMangledName(FuncDeclaration *fdecl, LINK link) {
|
||||||
std::string mangledName = mangleExact(fdecl);
|
std::string mangledName = mangleExact(fdecl);
|
||||||
|
|
||||||
// Hash the name if necessary
|
// Hash the name if necessary
|
||||||
|
@ -111,10 +111,10 @@ std::string DtoMangledName(FuncDeclaration *fdecl, LINK link) {
|
||||||
|
|
||||||
// TODO: Cache the result?
|
// TODO: Cache the result?
|
||||||
|
|
||||||
return DtoMangledFuncName(std::move(mangledName), link);
|
return getIRMangledFuncName(std::move(mangledName), link);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DtoMangledName(VarDeclaration *vd) {
|
std::string getIRMangledName(VarDeclaration *vd) {
|
||||||
OutBuffer mangleBuf;
|
OutBuffer mangleBuf;
|
||||||
mangleToBuffer(vd, &mangleBuf);
|
mangleToBuffer(vd, &mangleBuf);
|
||||||
|
|
||||||
|
@ -122,19 +122,19 @@ std::string DtoMangledName(VarDeclaration *vd) {
|
||||||
|
|
||||||
// TODO: Cache the result?
|
// TODO: Cache the result?
|
||||||
|
|
||||||
return DtoMangledVarName(mangleBuf.peekString(), vd->linkage);
|
return getIRMangledVarName(mangleBuf.peekString(), vd->linkage);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DtoMangledFuncName(std::string baseMangle, LINK link) {
|
std::string getIRMangledFuncName(std::string baseMangle, LINK link) {
|
||||||
return gABI->mangleFunctionForLLVM(std::move(baseMangle), link);
|
return gABI->mangleFunctionForLLVM(std::move(baseMangle), link);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DtoMangledVarName(std::string baseMangle, LINK link) {
|
std::string getIRMangledVarName(std::string baseMangle, LINK link) {
|
||||||
return gABI->mangleVariableForLLVM(std::move(baseMangle), link);
|
return gABI->mangleVariableForLLVM(std::move(baseMangle), link);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
std::string DtoMangledAggregateName(AggregateDeclaration *ad,
|
std::string getIRMangledAggregateName(AggregateDeclaration *ad,
|
||||||
const char *suffix) {
|
const char *suffix) {
|
||||||
std::string ret = "_D";
|
std::string ret = "_D";
|
||||||
|
|
||||||
|
@ -151,41 +151,41 @@ std::string DtoMangledAggregateName(AggregateDeclaration *ad,
|
||||||
if (suffix)
|
if (suffix)
|
||||||
ret += suffix;
|
ret += suffix;
|
||||||
|
|
||||||
return DtoMangledVarName(std::move(ret), LINKd);
|
return getIRMangledVarName(std::move(ret), LINKd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DtoMangledInitSymbolName(AggregateDeclaration *aggrdecl) {
|
std::string getIRMangledInitSymbolName(AggregateDeclaration *aggrdecl) {
|
||||||
return DtoMangledAggregateName(aggrdecl, "6__initZ");
|
return getIRMangledAggregateName(aggrdecl, "6__initZ");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DtoMangledVTableSymbolName(AggregateDeclaration *aggrdecl) {
|
std::string getIRMangledVTableSymbolName(AggregateDeclaration *aggrdecl) {
|
||||||
return DtoMangledAggregateName(aggrdecl, "6__vtblZ");
|
return getIRMangledAggregateName(aggrdecl, "6__vtblZ");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DtoMangledClassInfoSymbolName(AggregateDeclaration *aggrdecl) {
|
std::string getIRMangledClassInfoSymbolName(AggregateDeclaration *aggrdecl) {
|
||||||
const char *suffix =
|
const char *suffix =
|
||||||
aggrdecl->isInterfaceDeclaration() ? "11__InterfaceZ" : "7__ClassZ";
|
aggrdecl->isInterfaceDeclaration() ? "11__InterfaceZ" : "7__ClassZ";
|
||||||
return DtoMangledAggregateName(aggrdecl, suffix);
|
return getIRMangledAggregateName(aggrdecl, suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DtoMangledInterfaceInfosSymbolName(ClassDeclaration *cd) {
|
std::string getIRMangledInterfaceInfosSymbolName(ClassDeclaration *cd) {
|
||||||
OutBuffer mangledName;
|
OutBuffer mangledName;
|
||||||
mangledName.writestring("_D");
|
mangledName.writestring("_D");
|
||||||
mangleToBuffer(cd, &mangledName);
|
mangleToBuffer(cd, &mangledName);
|
||||||
mangledName.writestring("16__interfaceInfosZ");
|
mangledName.writestring("16__interfaceInfosZ");
|
||||||
return DtoMangledVarName(mangledName.peekString(), LINKd);
|
return getIRMangledVarName(mangledName.peekString(), LINKd);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DtoMangledModuleInfoSymbolName(Module *module) {
|
std::string getIRMangledModuleInfoSymbolName(Module *module) {
|
||||||
OutBuffer mangledName;
|
OutBuffer mangledName;
|
||||||
mangledName.writestring("_D");
|
mangledName.writestring("_D");
|
||||||
mangleToBuffer(module, &mangledName);
|
mangleToBuffer(module, &mangledName);
|
||||||
mangledName.writestring("12__ModuleInfoZ");
|
mangledName.writestring("12__ModuleInfoZ");
|
||||||
return DtoMangledVarName(mangledName.peekString(), LINKd);
|
return getIRMangledVarName(mangledName.peekString(), LINKd);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DtoMangledModuleRefSymbolName(const char *moduleMangle) {
|
std::string getIRMangledModuleRefSymbolName(const char *moduleMangle) {
|
||||||
return DtoMangledVarName(
|
return getIRMangledVarName(
|
||||||
(llvm::Twine("_D") + moduleMangle + "11__moduleRefZ").str(), LINKd);
|
(llvm::Twine("_D") + moduleMangle + "11__moduleRefZ").str(), LINKd);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,17 +30,17 @@ class VarDeclaration;
|
||||||
* byte. The TargetABI gets a chance to tweak the LLVM mangle.
|
* byte. The TargetABI gets a chance to tweak the LLVM mangle.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
std::string DtoMangledName(FuncDeclaration *fdecl, LINK link);
|
std::string getIRMangledName(FuncDeclaration *fdecl, LINK link);
|
||||||
std::string DtoMangledName(VarDeclaration *vd);
|
std::string getIRMangledName(VarDeclaration *vd);
|
||||||
|
|
||||||
std::string DtoMangledFuncName(std::string baseMangle, LINK link);
|
std::string getIRMangledFuncName(std::string baseMangle, LINK link);
|
||||||
std::string DtoMangledVarName(std::string baseMangle, LINK link);
|
std::string getIRMangledVarName(std::string baseMangle, LINK link);
|
||||||
|
|
||||||
std::string DtoMangledInitSymbolName(AggregateDeclaration *aggrdecl);
|
std::string getIRMangledInitSymbolName(AggregateDeclaration *aggrdecl);
|
||||||
std::string DtoMangledVTableSymbolName(AggregateDeclaration *aggrdecl);
|
std::string getIRMangledVTableSymbolName(AggregateDeclaration *aggrdecl);
|
||||||
std::string DtoMangledClassInfoSymbolName(AggregateDeclaration *aggrdecl);
|
std::string getIRMangledClassInfoSymbolName(AggregateDeclaration *aggrdecl);
|
||||||
std::string DtoMangledInterfaceInfosSymbolName(ClassDeclaration *cd);
|
std::string getIRMangledInterfaceInfosSymbolName(ClassDeclaration *cd);
|
||||||
std::string DtoMangledModuleInfoSymbolName(Module *module);
|
std::string getIRMangledModuleInfoSymbolName(Module *module);
|
||||||
std::string DtoMangledModuleRefSymbolName(const char *moduleMangle);
|
std::string getIRMangledModuleRefSymbolName(const char *moduleMangle);
|
||||||
|
|
||||||
#endif // LDC_GEN_MANGLING_H
|
#endif // LDC_GEN_MANGLING_H
|
||||||
|
|
|
@ -57,10 +57,10 @@ llvm::Function *buildForwarderFunction(
|
||||||
const auto fnTy =
|
const auto fnTy =
|
||||||
LLFunctionType::get(LLType::getVoidTy(gIR->context()), {}, false);
|
LLFunctionType::get(LLType::getVoidTy(gIR->context()), {}, false);
|
||||||
|
|
||||||
const auto llMangle = DtoMangledFuncName(name, LINKd);
|
const auto irMangle = getIRMangledFuncName(name, LINKd);
|
||||||
assert(gIR->module.getFunction(llMangle) == NULL);
|
assert(gIR->module.getFunction(irMangle) == NULL);
|
||||||
llvm::Function *fn = llvm::Function::Create(
|
llvm::Function *fn = llvm::Function::Create(
|
||||||
fnTy, llvm::GlobalValue::InternalLinkage, llMangle, &gIR->module);
|
fnTy, llvm::GlobalValue::InternalLinkage, irMangle, &gIR->module);
|
||||||
fn->setCallingConv(gABI->callingConv(LINKd));
|
fn->setCallingConv(gABI->callingConv(LINKd));
|
||||||
|
|
||||||
// Emit the body, consisting of...
|
// Emit the body, consisting of...
|
||||||
|
|
|
@ -148,7 +148,7 @@ LLFunction *build_module_reference_and_ctor(const char *moduleMangle,
|
||||||
// linked list
|
// linked list
|
||||||
LLFunction *ctor =
|
LLFunction *ctor =
|
||||||
LLFunction::Create(fty, LLGlobalValue::InternalLinkage,
|
LLFunction::Create(fty, LLGlobalValue::InternalLinkage,
|
||||||
DtoMangledFuncName(fname, LINKd), &gIR->module);
|
getIRMangledFuncName(fname, LINKd), &gIR->module);
|
||||||
|
|
||||||
// provide the default initializer
|
// provide the default initializer
|
||||||
LLStructType *modulerefTy = DtoModuleReferenceType();
|
LLStructType *modulerefTy = DtoModuleReferenceType();
|
||||||
|
@ -160,19 +160,19 @@ LLFunction *build_module_reference_and_ctor(const char *moduleMangle,
|
||||||
modulerefTy, llvm::ArrayRef<LLConstant *>(mrefvalues));
|
modulerefTy, llvm::ArrayRef<LLConstant *>(mrefvalues));
|
||||||
|
|
||||||
// create the ModuleReference node for this module
|
// create the ModuleReference node for this module
|
||||||
const auto thismrefLLMangle = DtoMangledModuleRefSymbolName(moduleMangle);
|
const auto thismrefIRMangle = getIRMangledModuleRefSymbolName(moduleMangle);
|
||||||
Loc loc;
|
Loc loc;
|
||||||
LLGlobalVariable *thismref = getOrCreateGlobal(
|
LLGlobalVariable *thismref = getOrCreateGlobal(
|
||||||
loc, gIR->module, modulerefTy, false, LLGlobalValue::InternalLinkage,
|
loc, gIR->module, modulerefTy, false, LLGlobalValue::InternalLinkage,
|
||||||
thismrefinit, thismrefLLMangle);
|
thismrefinit, thismrefIRMangle);
|
||||||
// make sure _Dmodule_ref is declared
|
// make sure _Dmodule_ref is declared
|
||||||
const auto mrefLLMangle = DtoMangledVarName("_Dmodule_ref", LINKc);
|
const auto mrefIRMangle = getIRMangledVarName("_Dmodule_ref", LINKc);
|
||||||
LLConstant *mref = gIR->module.getNamedGlobal(mrefLLMangle);
|
LLConstant *mref = gIR->module.getNamedGlobal(mrefIRMangle);
|
||||||
LLType *modulerefPtrTy = getPtrToType(modulerefTy);
|
LLType *modulerefPtrTy = getPtrToType(modulerefTy);
|
||||||
if (!mref) {
|
if (!mref) {
|
||||||
mref = new LLGlobalVariable(gIR->module, modulerefPtrTy, false,
|
mref = new LLGlobalVariable(gIR->module, modulerefPtrTy, false,
|
||||||
LLGlobalValue::ExternalLinkage, nullptr,
|
LLGlobalValue::ExternalLinkage, nullptr,
|
||||||
mrefLLMangle);
|
mrefIRMangle);
|
||||||
}
|
}
|
||||||
mref = DtoBitCast(mref, getPtrToType(modulerefPtrTy));
|
mref = DtoBitCast(mref, getPtrToType(modulerefPtrTy));
|
||||||
|
|
||||||
|
@ -343,13 +343,13 @@ void emitModuleRefToSection(RegistryStyle style, std::string moduleMangle,
|
||||||
|
|
||||||
llvm::Type *const moduleInfoPtrTy = DtoPtrToType(Module::moduleinfo->type);
|
llvm::Type *const moduleInfoPtrTy = DtoPtrToType(Module::moduleinfo->type);
|
||||||
|
|
||||||
const auto thismrefLLMangle =
|
const auto thismrefIRMangle =
|
||||||
DtoMangledModuleRefSymbolName(moduleMangle.c_str());
|
getIRMangledModuleRefSymbolName(moduleMangle.c_str());
|
||||||
auto thismref = new llvm::GlobalVariable(
|
auto thismref = new llvm::GlobalVariable(
|
||||||
gIR->module, moduleInfoPtrTy,
|
gIR->module, moduleInfoPtrTy,
|
||||||
false, // FIXME: mRelocModel != llvm::Reloc::PIC_
|
false, // FIXME: mRelocModel != llvm::Reloc::PIC_
|
||||||
llvm::GlobalValue::LinkOnceODRLinkage,
|
llvm::GlobalValue::LinkOnceODRLinkage,
|
||||||
DtoBitCast(thisModuleInfo, moduleInfoPtrTy), thismrefLLMangle);
|
DtoBitCast(thisModuleInfo, moduleInfoPtrTy), thismrefIRMangle);
|
||||||
thismref->setSection((style == RegistryStyle::sectionDarwin) ? "__DATA,.minfo"
|
thismref->setSection((style == RegistryStyle::sectionDarwin) ? "__DATA,.minfo"
|
||||||
: "__minfo");
|
: "__minfo");
|
||||||
gIR->usedArray.push_back(thismref);
|
gIR->usedArray.push_back(thismref);
|
||||||
|
@ -546,7 +546,7 @@ void addCoverageAnalysis(Module *m) {
|
||||||
LLFunctionType::get(LLType::getVoidTy(gIR->context()), {}, false);
|
LLFunctionType::get(LLType::getVoidTy(gIR->context()), {}, false);
|
||||||
ctor =
|
ctor =
|
||||||
LLFunction::Create(ctorTy, LLGlobalValue::InternalLinkage,
|
LLFunction::Create(ctorTy, LLGlobalValue::InternalLinkage,
|
||||||
DtoMangledFuncName(ctorname, LINKd), &gIR->module);
|
getIRMangledFuncName(ctorname, LINKd), &gIR->module);
|
||||||
ctor->setCallingConv(gABI->callingConv(LINKd));
|
ctor->setCallingConv(gABI->callingConv(LINKd));
|
||||||
// Set function attributes. See functions.cpp:DtoDefineFunction()
|
// Set function attributes. See functions.cpp:DtoDefineFunction()
|
||||||
if (global.params.targetTriple->getArch() == llvm::Triple::x86_64) {
|
if (global.params.targetTriple->getArch() == llvm::Triple::x86_64) {
|
||||||
|
|
|
@ -683,7 +683,7 @@ static void buildRuntimeModule() {
|
||||||
// void invariant._d_invariant(Object o)
|
// void invariant._d_invariant(Object o)
|
||||||
createFwdDecl(
|
createFwdDecl(
|
||||||
LINKd, voidTy,
|
LINKd, voidTy,
|
||||||
{DtoMangledFuncName("_D9invariant12_d_invariantFC6ObjectZv", LINKd)},
|
{getIRMangledFuncName("_D9invariant12_d_invariantFC6ObjectZv", LINKd)},
|
||||||
{objectTy});
|
{objectTy});
|
||||||
|
|
||||||
// void _d_dso_registry(void* data)
|
// void _d_dso_registry(void* data)
|
||||||
|
|
|
@ -1689,7 +1689,7 @@ public:
|
||||||
Logger::println("calling class invariant");
|
Logger::println("calling class invariant");
|
||||||
|
|
||||||
const auto fnMangle =
|
const auto fnMangle =
|
||||||
DtoMangledFuncName("_D9invariant12_d_invariantFC6ObjectZv", LINKd);
|
getIRMangledFuncName("_D9invariant12_d_invariantFC6ObjectZv", LINKd);
|
||||||
const auto fn = getRuntimeFunction(e->loc, gIR->module, fnMangle.c_str());
|
const auto fn = getRuntimeFunction(e->loc, gIR->module, fnMangle.c_str());
|
||||||
|
|
||||||
const auto arg =
|
const auto arg =
|
||||||
|
|
|
@ -593,11 +593,11 @@ void TypeInfoDeclaration_codegen(TypeInfoDeclaration *decl, IRState *p) {
|
||||||
Logger::println("typeinfo mangle: %s", mangled);
|
Logger::println("typeinfo mangle: %s", mangled);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto llMangle = DtoMangledVarName(mangled, LINKd);
|
const auto irMangle = getIRMangledVarName(mangled, LINKd);
|
||||||
IrGlobal *irg = getIrGlobal(decl, true);
|
IrGlobal *irg = getIrGlobal(decl, true);
|
||||||
const LinkageWithCOMDAT lwc(LLGlobalValue::ExternalLinkage, false);
|
const LinkageWithCOMDAT lwc(LLGlobalValue::ExternalLinkage, false);
|
||||||
|
|
||||||
irg->value = gIR->module.getGlobalVariable(llMangle);
|
irg->value = gIR->module.getGlobalVariable(irMangle);
|
||||||
if (irg->value) {
|
if (irg->value) {
|
||||||
assert(irg->getType()->isStructTy());
|
assert(irg->getType()->isStructTy());
|
||||||
} else {
|
} else {
|
||||||
|
@ -612,7 +612,7 @@ void TypeInfoDeclaration_codegen(TypeInfoDeclaration *decl, IRState *p) {
|
||||||
// as immutable on the D side, and e.g. synchronized() can be used on the
|
// as immutable on the D side, and e.g. synchronized() can be used on the
|
||||||
// implicit monitor.
|
// implicit monitor.
|
||||||
auto g = new LLGlobalVariable(gIR->module, type, false, lwc.first,
|
auto g = new LLGlobalVariable(gIR->module, type, false, lwc.first,
|
||||||
nullptr, llMangle);
|
nullptr, irMangle);
|
||||||
setLinkage(lwc, g);
|
setLinkage(lwc, g);
|
||||||
irg->value = g;
|
irg->value = g;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,11 +47,11 @@ LLConstant *&IrAggr::getInitSymbol() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the initZ symbol
|
// create the initZ symbol
|
||||||
const auto llMangle = DtoMangledInitSymbolName(aggrdecl);
|
const auto irMangle = getIRMangledInitSymbolName(aggrdecl);
|
||||||
|
|
||||||
auto initGlobal =
|
auto initGlobal =
|
||||||
getOrCreateGlobal(aggrdecl->loc, gIR->module, getLLStructType(), true,
|
getOrCreateGlobal(aggrdecl->loc, gIR->module, getLLStructType(), true,
|
||||||
llvm::GlobalValue::ExternalLinkage, nullptr, llMangle);
|
llvm::GlobalValue::ExternalLinkage, nullptr, irMangle);
|
||||||
initGlobal->setAlignment(DtoAlignment(type));
|
initGlobal->setAlignment(DtoAlignment(type));
|
||||||
|
|
||||||
init = initGlobal;
|
init = initGlobal;
|
||||||
|
|
|
@ -47,13 +47,13 @@ LLGlobalVariable *IrAggr::getVtblSymbol() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the vtblZ symbol
|
// create the vtblZ symbol
|
||||||
const auto llMangle = DtoMangledVTableSymbolName(aggrdecl);
|
const auto irMangle = getIRMangledVTableSymbolName(aggrdecl);
|
||||||
|
|
||||||
LLType *vtblTy = stripModifiers(type)->ctype->isClass()->getVtblType();
|
LLType *vtblTy = stripModifiers(type)->ctype->isClass()->getVtblType();
|
||||||
|
|
||||||
vtbl =
|
vtbl =
|
||||||
getOrCreateGlobal(aggrdecl->loc, gIR->module, vtblTy, true,
|
getOrCreateGlobal(aggrdecl->loc, gIR->module, vtblTy, true,
|
||||||
llvm::GlobalValue::ExternalLinkage, nullptr, llMangle);
|
llvm::GlobalValue::ExternalLinkage, nullptr, irMangle);
|
||||||
|
|
||||||
return vtbl;
|
return vtbl;
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ LLGlobalVariable *IrAggr::getClassInfoSymbol() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the ClassZ / InterfaceZ symbol
|
// create the ClassZ / InterfaceZ symbol
|
||||||
const auto llMangle = DtoMangledClassInfoSymbolName(aggrdecl);
|
const auto irMangle = getIRMangledClassInfoSymbolName(aggrdecl);
|
||||||
|
|
||||||
// The type is also ClassInfo for interfaces – the actual TypeInfo for them
|
// The type is also ClassInfo for interfaces – the actual TypeInfo for them
|
||||||
// is a TypeInfo_Interface instance that references __ClassZ in its "base"
|
// is a TypeInfo_Interface instance that references __ClassZ in its "base"
|
||||||
|
@ -79,7 +79,7 @@ LLGlobalVariable *IrAggr::getClassInfoSymbol() {
|
||||||
// classinfos cannot be constants since they're used as locks for synchronized
|
// classinfos cannot be constants since they're used as locks for synchronized
|
||||||
classInfo = getOrCreateGlobal(
|
classInfo = getOrCreateGlobal(
|
||||||
aggrdecl->loc, gIR->module, tc->getMemoryLLType(), false,
|
aggrdecl->loc, gIR->module, tc->getMemoryLLType(), false,
|
||||||
llvm::GlobalValue::ExternalLinkage, nullptr, llMangle);
|
llvm::GlobalValue::ExternalLinkage, nullptr, irMangle);
|
||||||
|
|
||||||
// Generate some metadata on this ClassInfo if it's for a class.
|
// Generate some metadata on this ClassInfo if it's for a class.
|
||||||
ClassDeclaration *classdecl = aggrdecl->isClassDeclaration();
|
ClassDeclaration *classdecl = aggrdecl->isClassDeclaration();
|
||||||
|
@ -100,10 +100,10 @@ LLGlobalVariable *IrAggr::getClassInfoSymbol() {
|
||||||
// Construct the metadata and insert it into the module.
|
// Construct the metadata and insert it into the module.
|
||||||
OutBuffer debugName;
|
OutBuffer debugName;
|
||||||
debugName.writestring(CD_PREFIX);
|
debugName.writestring(CD_PREFIX);
|
||||||
if (llMangle[0] == '\1') {
|
if (irMangle[0] == '\1') {
|
||||||
debugName.write(llMangle.data() + 1, llMangle.length() - 1);
|
debugName.write(irMangle.data() + 1, irMangle.length() - 1);
|
||||||
} else {
|
} else {
|
||||||
debugName.write(llMangle.data(), llMangle.length());
|
debugName.write(irMangle.data(), irMangle.length());
|
||||||
}
|
}
|
||||||
llvm::NamedMDNode *node =
|
llvm::NamedMDNode *node =
|
||||||
gIR->module.getOrInsertNamedMetadata(debugName.peekString());
|
gIR->module.getOrInsertNamedMetadata(debugName.peekString());
|
||||||
|
@ -130,7 +130,7 @@ LLGlobalVariable *IrAggr::getInterfaceArraySymbol() {
|
||||||
LLType *InterfaceTy = DtoType(Type::typeinfoclass->fields[3]->type->nextOf());
|
LLType *InterfaceTy = DtoType(Type::typeinfoclass->fields[3]->type->nextOf());
|
||||||
|
|
||||||
// create Interface[N]
|
// create Interface[N]
|
||||||
const auto llMangle = DtoMangledInterfaceInfosSymbolName(cd);
|
const auto irMangle = getIRMangledInterfaceInfosSymbolName(cd);
|
||||||
|
|
||||||
LLArrayType *array_type = llvm::ArrayType::get(InterfaceTy, n);
|
LLArrayType *array_type = llvm::ArrayType::get(InterfaceTy, n);
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ LLGlobalVariable *IrAggr::getInterfaceArraySymbol() {
|
||||||
// if we emit the initializer later.
|
// if we emit the initializer later.
|
||||||
classInterfacesArray =
|
classInterfacesArray =
|
||||||
getOrCreateGlobal(cd->loc, gIR->module, array_type, true,
|
getOrCreateGlobal(cd->loc, gIR->module, array_type, true,
|
||||||
llvm::GlobalValue::ExternalLinkage, nullptr, llMangle);
|
llvm::GlobalValue::ExternalLinkage, nullptr, irMangle);
|
||||||
|
|
||||||
return classInterfacesArray;
|
return classInterfacesArray;
|
||||||
}
|
}
|
||||||
|
@ -332,17 +332,17 @@ llvm::GlobalVariable *IrAggr::getInterfaceVtbl(BaseClass *b, bool new_instance,
|
||||||
nameBuf.writestring(thunkPrefix);
|
nameBuf.writestring(thunkPrefix);
|
||||||
nameBuf.writestring(mangledTargetName + 2);
|
nameBuf.writestring(mangledTargetName + 2);
|
||||||
|
|
||||||
const auto thunkLLMangle =
|
const auto thunkIRMangle =
|
||||||
DtoMangledFuncName(nameBuf.peekString(), fd->linkage);
|
getIRMangledFuncName(nameBuf.peekString(), fd->linkage);
|
||||||
|
|
||||||
llvm::Function *thunk = gIR->module.getFunction(thunkLLMangle);
|
llvm::Function *thunk = gIR->module.getFunction(thunkIRMangle);
|
||||||
if (!thunk) {
|
if (!thunk) {
|
||||||
const LinkageWithCOMDAT lwc(LLGlobalValue::LinkOnceODRLinkage,
|
const LinkageWithCOMDAT lwc(LLGlobalValue::LinkOnceODRLinkage,
|
||||||
supportsCOMDAT());
|
supportsCOMDAT());
|
||||||
const auto callee = irFunc->getLLVMCallee();
|
const auto callee = irFunc->getLLVMCallee();
|
||||||
thunk = LLFunction::Create(
|
thunk = LLFunction::Create(
|
||||||
isaFunction(callee->getType()->getContainedType(0)), lwc.first,
|
isaFunction(callee->getType()->getContainedType(0)), lwc.first,
|
||||||
thunkLLMangle, &gIR->module);
|
thunkIRMangle, &gIR->module);
|
||||||
setLinkage(lwc, thunk);
|
setLinkage(lwc, thunk);
|
||||||
thunk->copyAttributesFrom(callee);
|
thunk->copyAttributesFrom(callee);
|
||||||
|
|
||||||
|
@ -445,12 +445,12 @@ llvm::GlobalVariable *IrAggr::getInterfaceVtbl(BaseClass *b, bool new_instance,
|
||||||
mangledName.writestring(thunkPrefix);
|
mangledName.writestring(thunkPrefix);
|
||||||
mangledName.writestring("6__vtblZ");
|
mangledName.writestring("6__vtblZ");
|
||||||
|
|
||||||
const auto llMangle = DtoMangledVarName(mangledName.peekString(), LINKd);
|
const auto irMangle = getIRMangledVarName(mangledName.peekString(), LINKd);
|
||||||
|
|
||||||
const auto lwc = DtoLinkage(cd);
|
const auto lwc = DtoLinkage(cd);
|
||||||
LLGlobalVariable *GV =
|
LLGlobalVariable *GV =
|
||||||
getOrCreateGlobal(cd->loc, gIR->module, vtbl_constant->getType(), true,
|
getOrCreateGlobal(cd->loc, gIR->module, vtbl_constant->getType(), true,
|
||||||
lwc.first, vtbl_constant, llMangle);
|
lwc.first, vtbl_constant, irMangle);
|
||||||
setLinkage(lwc, GV);
|
setLinkage(lwc, GV);
|
||||||
|
|
||||||
// insert into the vtbl map
|
// insert into the vtbl map
|
||||||
|
|
|
@ -23,11 +23,11 @@ llvm::GlobalVariable *IrModule::moduleInfoSymbol() {
|
||||||
return moduleInfoVar;
|
return moduleInfoVar;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto llMangle = DtoMangledModuleInfoSymbolName(M);
|
const auto irMangle = getIRMangledModuleInfoSymbolName(M);
|
||||||
|
|
||||||
moduleInfoVar = new llvm::GlobalVariable(
|
moduleInfoVar = new llvm::GlobalVariable(
|
||||||
gIR->module, llvm::StructType::create(gIR->context()), false,
|
gIR->module, llvm::StructType::create(gIR->context()), false,
|
||||||
llvm::GlobalValue::ExternalLinkage, nullptr, llMangle);
|
llvm::GlobalValue::ExternalLinkage, nullptr, irMangle);
|
||||||
return moduleInfoVar;
|
return moduleInfoVar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue