llvm::GlobalVariable* LLVM_D_GetRuntimeGlobal(llvm::Module* target, const char* name) { LLGlobalVariable* gv = target->getNamedGlobal(name); if (gv) { return gv; } if (noruntime) { error("No implicit runtime calls allowed with -noruntime option enabled"); fatal(); } if (!M) { LLVM_D_InitRuntime(); } LLGlobalVariable* g = M->getNamedGlobal(name); if (!g) { error("Runtime global '%s' was not found", name); fatal(); //return NULL; } LLPointerType* t = g->getType(); return new LLGlobalVariable(*target, t->getElementType(), g->isConstant(), g->getLinkage(), NULL, g->getName()); }
llvm::GlobalVariable *getRuntimeGlobal(Loc &loc, llvm::Module &target, const char *name) { LLGlobalVariable *gv = target.getNamedGlobal(name); if (gv) { return gv; } checkForImplicitGCCall(loc, name); if (!M) { initRuntime(); } LLGlobalVariable *g = M->getNamedGlobal(name); if (!g) { error(loc, "Runtime global '%s' was not found", name); fatal(); // return NULL; } LLPointerType *t = g->getType(); return getOrCreateGlobal(loc, target, t->getElementType(), g->isConstant(), g->getLinkage(), nullptr, g->getName()); }