diff --git a/gen/functions.cpp b/gen/functions.cpp index cce1ca1995..cca39b1fa4 100644 --- a/gen/functions.cpp +++ b/gen/functions.cpp @@ -522,16 +522,16 @@ void DtoDeclareFunction(FuncDeclaration *fdecl) { const auto link = forceC ? LINKc : f->linkage; // mangled name - const auto llMangle = DtoMangledName(fdecl, link); + const auto irMangle = getIRMangledName(fdecl, link); // construct function LLFunctionType *functype = DtoFunctionType(fdecl); - LLFunction *func = vafunc ? vafunc : gIR->module.getFunction(llMangle); + LLFunction *func = vafunc ? vafunc : gIR->module.getFunction(irMangle); if (!func) { // All function declarations are "external" - any other linkage type // is set when actually defining the function. func = LLFunction::Create(functype, llvm::GlobalValue::ExternalLinkage, - llMangle, &gIR->module); + irMangle, &gIR->module); } else if (func->getFunctionType() != functype) { error(fdecl->loc, "Function type does not match previously declared " diff --git a/gen/llvmhelpers.cpp b/gen/llvmhelpers.cpp index 002bd697c4..1c59847ec3 100644 --- a/gen/llvmhelpers.cpp +++ b/gen/llvmhelpers.cpp @@ -834,7 +834,7 @@ void DtoResolveVariable(VarDeclaration *vd) { if (gIR->dmodule) { 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 // initializer, we cannot know the type until after we have emitted the @@ -855,7 +855,7 @@ void DtoResolveVariable(VarDeclaration *vd) { llvm::GlobalVariable *gvar = getOrCreateGlobal(vd->loc, gIR->module, DtoMemType(vd->type), isLLConst, - linkage, nullptr, llMangle, vd->isThreadlocal()); + linkage, nullptr, irMangle, vd->isThreadlocal()); getIrGlobal(vd)->value = gvar; // Set the alignment (it is important not to use type->alignsize because diff --git a/gen/mangling.cpp b/gen/mangling.cpp index 81fdc60ebd..ef4d1c27e5 100644 --- a/gen/mangling.cpp +++ b/gen/mangling.cpp @@ -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); // Hash the name if necessary @@ -111,10 +111,10 @@ std::string DtoMangledName(FuncDeclaration *fdecl, LINK link) { // 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; mangleToBuffer(vd, &mangleBuf); @@ -122,19 +122,19 @@ std::string DtoMangledName(VarDeclaration *vd) { // 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); } -std::string DtoMangledVarName(std::string baseMangle, LINK link) { +std::string getIRMangledVarName(std::string baseMangle, LINK link) { return gABI->mangleVariableForLLVM(std::move(baseMangle), link); } namespace { -std::string DtoMangledAggregateName(AggregateDeclaration *ad, +std::string getIRMangledAggregateName(AggregateDeclaration *ad, const char *suffix) { std::string ret = "_D"; @@ -151,41 +151,41 @@ std::string DtoMangledAggregateName(AggregateDeclaration *ad, if (suffix) ret += suffix; - return DtoMangledVarName(std::move(ret), LINKd); + return getIRMangledVarName(std::move(ret), LINKd); } } -std::string DtoMangledInitSymbolName(AggregateDeclaration *aggrdecl) { - return DtoMangledAggregateName(aggrdecl, "6__initZ"); +std::string getIRMangledInitSymbolName(AggregateDeclaration *aggrdecl) { + return getIRMangledAggregateName(aggrdecl, "6__initZ"); } -std::string DtoMangledVTableSymbolName(AggregateDeclaration *aggrdecl) { - return DtoMangledAggregateName(aggrdecl, "6__vtblZ"); +std::string getIRMangledVTableSymbolName(AggregateDeclaration *aggrdecl) { + return getIRMangledAggregateName(aggrdecl, "6__vtblZ"); } -std::string DtoMangledClassInfoSymbolName(AggregateDeclaration *aggrdecl) { +std::string getIRMangledClassInfoSymbolName(AggregateDeclaration *aggrdecl) { const char *suffix = 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; mangledName.writestring("_D"); mangleToBuffer(cd, &mangledName); 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; mangledName.writestring("_D"); mangleToBuffer(module, &mangledName); mangledName.writestring("12__ModuleInfoZ"); - return DtoMangledVarName(mangledName.peekString(), LINKd); + return getIRMangledVarName(mangledName.peekString(), LINKd); } -std::string DtoMangledModuleRefSymbolName(const char *moduleMangle) { - return DtoMangledVarName( +std::string getIRMangledModuleRefSymbolName(const char *moduleMangle) { + return getIRMangledVarName( (llvm::Twine("_D") + moduleMangle + "11__moduleRefZ").str(), LINKd); } diff --git a/gen/mangling.h b/gen/mangling.h index afd9d18219..065c01e70b 100644 --- a/gen/mangling.h +++ b/gen/mangling.h @@ -30,17 +30,17 @@ class VarDeclaration; * byte. The TargetABI gets a chance to tweak the LLVM mangle. */ -std::string DtoMangledName(FuncDeclaration *fdecl, LINK link); -std::string DtoMangledName(VarDeclaration *vd); +std::string getIRMangledName(FuncDeclaration *fdecl, LINK link); +std::string getIRMangledName(VarDeclaration *vd); -std::string DtoMangledFuncName(std::string baseMangle, LINK link); -std::string DtoMangledVarName(std::string baseMangle, LINK link); +std::string getIRMangledFuncName(std::string baseMangle, LINK link); +std::string getIRMangledVarName(std::string baseMangle, LINK link); -std::string DtoMangledInitSymbolName(AggregateDeclaration *aggrdecl); -std::string DtoMangledVTableSymbolName(AggregateDeclaration *aggrdecl); -std::string DtoMangledClassInfoSymbolName(AggregateDeclaration *aggrdecl); -std::string DtoMangledInterfaceInfosSymbolName(ClassDeclaration *cd); -std::string DtoMangledModuleInfoSymbolName(Module *module); -std::string DtoMangledModuleRefSymbolName(const char *moduleMangle); +std::string getIRMangledInitSymbolName(AggregateDeclaration *aggrdecl); +std::string getIRMangledVTableSymbolName(AggregateDeclaration *aggrdecl); +std::string getIRMangledClassInfoSymbolName(AggregateDeclaration *aggrdecl); +std::string getIRMangledInterfaceInfosSymbolName(ClassDeclaration *cd); +std::string getIRMangledModuleInfoSymbolName(Module *module); +std::string getIRMangledModuleRefSymbolName(const char *moduleMangle); #endif // LDC_GEN_MANGLING_H diff --git a/gen/moduleinfo.cpp b/gen/moduleinfo.cpp index 9c023bbdba..0e0b4962d1 100644 --- a/gen/moduleinfo.cpp +++ b/gen/moduleinfo.cpp @@ -57,10 +57,10 @@ llvm::Function *buildForwarderFunction( const auto fnTy = LLFunctionType::get(LLType::getVoidTy(gIR->context()), {}, false); - const auto llMangle = DtoMangledFuncName(name, LINKd); - assert(gIR->module.getFunction(llMangle) == NULL); + const auto irMangle = getIRMangledFuncName(name, LINKd); + assert(gIR->module.getFunction(irMangle) == NULL); 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)); // Emit the body, consisting of... diff --git a/gen/modules.cpp b/gen/modules.cpp index aa82d2b4c2..72d2323fd0 100644 --- a/gen/modules.cpp +++ b/gen/modules.cpp @@ -148,7 +148,7 @@ LLFunction *build_module_reference_and_ctor(const char *moduleMangle, // linked list LLFunction *ctor = LLFunction::Create(fty, LLGlobalValue::InternalLinkage, - DtoMangledFuncName(fname, LINKd), &gIR->module); + getIRMangledFuncName(fname, LINKd), &gIR->module); // provide the default initializer LLStructType *modulerefTy = DtoModuleReferenceType(); @@ -160,19 +160,19 @@ LLFunction *build_module_reference_and_ctor(const char *moduleMangle, modulerefTy, llvm::ArrayRef(mrefvalues)); // create the ModuleReference node for this module - const auto thismrefLLMangle = DtoMangledModuleRefSymbolName(moduleMangle); + const auto thismrefIRMangle = getIRMangledModuleRefSymbolName(moduleMangle); Loc loc; LLGlobalVariable *thismref = getOrCreateGlobal( loc, gIR->module, modulerefTy, false, LLGlobalValue::InternalLinkage, - thismrefinit, thismrefLLMangle); + thismrefinit, thismrefIRMangle); // make sure _Dmodule_ref is declared - const auto mrefLLMangle = DtoMangledVarName("_Dmodule_ref", LINKc); - LLConstant *mref = gIR->module.getNamedGlobal(mrefLLMangle); + const auto mrefIRMangle = getIRMangledVarName("_Dmodule_ref", LINKc); + LLConstant *mref = gIR->module.getNamedGlobal(mrefIRMangle); LLType *modulerefPtrTy = getPtrToType(modulerefTy); if (!mref) { mref = new LLGlobalVariable(gIR->module, modulerefPtrTy, false, LLGlobalValue::ExternalLinkage, nullptr, - mrefLLMangle); + mrefIRMangle); } mref = DtoBitCast(mref, getPtrToType(modulerefPtrTy)); @@ -343,13 +343,13 @@ void emitModuleRefToSection(RegistryStyle style, std::string moduleMangle, llvm::Type *const moduleInfoPtrTy = DtoPtrToType(Module::moduleinfo->type); - const auto thismrefLLMangle = - DtoMangledModuleRefSymbolName(moduleMangle.c_str()); + const auto thismrefIRMangle = + getIRMangledModuleRefSymbolName(moduleMangle.c_str()); auto thismref = new llvm::GlobalVariable( gIR->module, moduleInfoPtrTy, false, // FIXME: mRelocModel != llvm::Reloc::PIC_ llvm::GlobalValue::LinkOnceODRLinkage, - DtoBitCast(thisModuleInfo, moduleInfoPtrTy), thismrefLLMangle); + DtoBitCast(thisModuleInfo, moduleInfoPtrTy), thismrefIRMangle); thismref->setSection((style == RegistryStyle::sectionDarwin) ? "__DATA,.minfo" : "__minfo"); gIR->usedArray.push_back(thismref); @@ -546,7 +546,7 @@ void addCoverageAnalysis(Module *m) { LLFunctionType::get(LLType::getVoidTy(gIR->context()), {}, false); ctor = LLFunction::Create(ctorTy, LLGlobalValue::InternalLinkage, - DtoMangledFuncName(ctorname, LINKd), &gIR->module); + getIRMangledFuncName(ctorname, LINKd), &gIR->module); ctor->setCallingConv(gABI->callingConv(LINKd)); // Set function attributes. See functions.cpp:DtoDefineFunction() if (global.params.targetTriple->getArch() == llvm::Triple::x86_64) { diff --git a/gen/runtime.cpp b/gen/runtime.cpp index 82f7c961fa..93e368285e 100644 --- a/gen/runtime.cpp +++ b/gen/runtime.cpp @@ -683,7 +683,7 @@ static void buildRuntimeModule() { // void invariant._d_invariant(Object o) createFwdDecl( LINKd, voidTy, - {DtoMangledFuncName("_D9invariant12_d_invariantFC6ObjectZv", LINKd)}, + {getIRMangledFuncName("_D9invariant12_d_invariantFC6ObjectZv", LINKd)}, {objectTy}); // void _d_dso_registry(void* data) diff --git a/gen/toir.cpp b/gen/toir.cpp index 74225fc328..57a68d005d 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -1689,7 +1689,7 @@ public: Logger::println("calling class invariant"); 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 arg = diff --git a/gen/typinf.cpp b/gen/typinf.cpp index c45a75d8df..a2a78e2c4a 100644 --- a/gen/typinf.cpp +++ b/gen/typinf.cpp @@ -593,11 +593,11 @@ void TypeInfoDeclaration_codegen(TypeInfoDeclaration *decl, IRState *p) { Logger::println("typeinfo mangle: %s", mangled); } - const auto llMangle = DtoMangledVarName(mangled, LINKd); + const auto irMangle = getIRMangledVarName(mangled, LINKd); IrGlobal *irg = getIrGlobal(decl, true); const LinkageWithCOMDAT lwc(LLGlobalValue::ExternalLinkage, false); - irg->value = gIR->module.getGlobalVariable(llMangle); + irg->value = gIR->module.getGlobalVariable(irMangle); if (irg->value) { assert(irg->getType()->isStructTy()); } 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 // implicit monitor. auto g = new LLGlobalVariable(gIR->module, type, false, lwc.first, - nullptr, llMangle); + nullptr, irMangle); setLinkage(lwc, g); irg->value = g; } diff --git a/ir/iraggr.cpp b/ir/iraggr.cpp index 085a4719bc..d17ede4c1c 100644 --- a/ir/iraggr.cpp +++ b/ir/iraggr.cpp @@ -47,11 +47,11 @@ LLConstant *&IrAggr::getInitSymbol() { } // create the initZ symbol - const auto llMangle = DtoMangledInitSymbolName(aggrdecl); + const auto irMangle = getIRMangledInitSymbolName(aggrdecl); auto initGlobal = getOrCreateGlobal(aggrdecl->loc, gIR->module, getLLStructType(), true, - llvm::GlobalValue::ExternalLinkage, nullptr, llMangle); + llvm::GlobalValue::ExternalLinkage, nullptr, irMangle); initGlobal->setAlignment(DtoAlignment(type)); init = initGlobal; diff --git a/ir/irclass.cpp b/ir/irclass.cpp index e6ca0532de..0430749f24 100644 --- a/ir/irclass.cpp +++ b/ir/irclass.cpp @@ -47,13 +47,13 @@ LLGlobalVariable *IrAggr::getVtblSymbol() { } // create the vtblZ symbol - const auto llMangle = DtoMangledVTableSymbolName(aggrdecl); + const auto irMangle = getIRMangledVTableSymbolName(aggrdecl); LLType *vtblTy = stripModifiers(type)->ctype->isClass()->getVtblType(); vtbl = getOrCreateGlobal(aggrdecl->loc, gIR->module, vtblTy, true, - llvm::GlobalValue::ExternalLinkage, nullptr, llMangle); + llvm::GlobalValue::ExternalLinkage, nullptr, irMangle); return vtbl; } @@ -66,7 +66,7 @@ LLGlobalVariable *IrAggr::getClassInfoSymbol() { } // 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 // 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 classInfo = getOrCreateGlobal( 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. ClassDeclaration *classdecl = aggrdecl->isClassDeclaration(); @@ -100,10 +100,10 @@ LLGlobalVariable *IrAggr::getClassInfoSymbol() { // Construct the metadata and insert it into the module. OutBuffer debugName; debugName.writestring(CD_PREFIX); - if (llMangle[0] == '\1') { - debugName.write(llMangle.data() + 1, llMangle.length() - 1); + if (irMangle[0] == '\1') { + debugName.write(irMangle.data() + 1, irMangle.length() - 1); } else { - debugName.write(llMangle.data(), llMangle.length()); + debugName.write(irMangle.data(), irMangle.length()); } llvm::NamedMDNode *node = gIR->module.getOrInsertNamedMetadata(debugName.peekString()); @@ -130,7 +130,7 @@ LLGlobalVariable *IrAggr::getInterfaceArraySymbol() { LLType *InterfaceTy = DtoType(Type::typeinfoclass->fields[3]->type->nextOf()); // create Interface[N] - const auto llMangle = DtoMangledInterfaceInfosSymbolName(cd); + const auto irMangle = getIRMangledInterfaceInfosSymbolName(cd); LLArrayType *array_type = llvm::ArrayType::get(InterfaceTy, n); @@ -138,7 +138,7 @@ LLGlobalVariable *IrAggr::getInterfaceArraySymbol() { // if we emit the initializer later. classInterfacesArray = getOrCreateGlobal(cd->loc, gIR->module, array_type, true, - llvm::GlobalValue::ExternalLinkage, nullptr, llMangle); + llvm::GlobalValue::ExternalLinkage, nullptr, irMangle); return classInterfacesArray; } @@ -332,17 +332,17 @@ llvm::GlobalVariable *IrAggr::getInterfaceVtbl(BaseClass *b, bool new_instance, nameBuf.writestring(thunkPrefix); nameBuf.writestring(mangledTargetName + 2); - const auto thunkLLMangle = - DtoMangledFuncName(nameBuf.peekString(), fd->linkage); + const auto thunkIRMangle = + getIRMangledFuncName(nameBuf.peekString(), fd->linkage); - llvm::Function *thunk = gIR->module.getFunction(thunkLLMangle); + llvm::Function *thunk = gIR->module.getFunction(thunkIRMangle); if (!thunk) { const LinkageWithCOMDAT lwc(LLGlobalValue::LinkOnceODRLinkage, supportsCOMDAT()); const auto callee = irFunc->getLLVMCallee(); thunk = LLFunction::Create( isaFunction(callee->getType()->getContainedType(0)), lwc.first, - thunkLLMangle, &gIR->module); + thunkIRMangle, &gIR->module); setLinkage(lwc, thunk); thunk->copyAttributesFrom(callee); @@ -445,12 +445,12 @@ llvm::GlobalVariable *IrAggr::getInterfaceVtbl(BaseClass *b, bool new_instance, mangledName.writestring(thunkPrefix); mangledName.writestring("6__vtblZ"); - const auto llMangle = DtoMangledVarName(mangledName.peekString(), LINKd); + const auto irMangle = getIRMangledVarName(mangledName.peekString(), LINKd); const auto lwc = DtoLinkage(cd); LLGlobalVariable *GV = getOrCreateGlobal(cd->loc, gIR->module, vtbl_constant->getType(), true, - lwc.first, vtbl_constant, llMangle); + lwc.first, vtbl_constant, irMangle); setLinkage(lwc, GV); // insert into the vtbl map diff --git a/ir/irmodule.cpp b/ir/irmodule.cpp index 0241c2d744..8d2eee839d 100644 --- a/ir/irmodule.cpp +++ b/ir/irmodule.cpp @@ -23,11 +23,11 @@ llvm::GlobalVariable *IrModule::moduleInfoSymbol() { return moduleInfoVar; } - const auto llMangle = DtoMangledModuleInfoSymbolName(M); + const auto irMangle = getIRMangledModuleInfoSymbolName(M); moduleInfoVar = new llvm::GlobalVariable( gIR->module, llvm::StructType::create(gIR->context()), false, - llvm::GlobalValue::ExternalLinkage, nullptr, llMangle); + llvm::GlobalValue::ExternalLinkage, nullptr, irMangle); return moduleInfoVar; }