From 48f1a9c507157aeea31839586d0c517769453b76 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Tue, 29 Apr 2008 21:33:50 +0200 Subject: [PATCH] [svn r171] starting to move IR data from AST nodes into IRState; started with IrFunction --- dmd/declaration.h | 2 -- dmd/func.c | 1 - gen/classes.cpp | 28 +++++++++++------------ gen/functions.cpp | 56 +++++++++++++++++++++++----------------------- gen/irstate.h | 3 +++ gen/statements.cpp | 4 ++-- gen/todebug.cpp | 8 +++---- gen/toir.cpp | 26 ++++++++++----------- gen/tollvm.cpp | 18 +++++++-------- gen/toobj.cpp | 12 +++++----- gen/typinf.cpp | 12 +++++----- 11 files changed, 85 insertions(+), 85 deletions(-) diff --git a/dmd/declaration.h b/dmd/declaration.h index 1570873f..15b4fe60 100644 --- a/dmd/declaration.h +++ b/dmd/declaration.h @@ -24,7 +24,6 @@ namespace llvm { class Value; } -struct IrFunction; struct IrVar; struct IrGlobal; struct IrLocal; @@ -614,7 +613,6 @@ struct FuncDeclaration : Declaration // llvmdc stuff bool runTimeHack; - IrFunction* irFunc; std::set nestedVars; }; diff --git a/dmd/func.c b/dmd/func.c index 4a3419cc..91bd5bbc 100644 --- a/dmd/func.c +++ b/dmd/func.c @@ -75,7 +75,6 @@ FuncDeclaration::FuncDeclaration(Loc loc, Loc endloc, Identifier *id, enum STC s shidden = NULL; // llvmdc runTimeHack = false; - irFunc = NULL; } Dsymbol *FuncDeclaration::syntaxCopy(Dsymbol *s) diff --git a/gen/classes.cpp b/gen/classes.cpp index bb6d4990..07db7916 100644 --- a/gen/classes.cpp +++ b/gen/classes.cpp @@ -553,8 +553,8 @@ void DtoConstInitClass(ClassDeclaration* cd) if (FuncDeclaration* fd = dsym->isFuncDeclaration()) { DtoForceDeclareDsymbol(fd); - assert(fd->irFunc->func); - llvm::Constant* c = llvm::cast(fd->irFunc->func); + assert(gIR->irFunc[fd]->func); + llvm::Constant* c = llvm::cast(gIR->irFunc[fd]->func); // cast if necessary (overridden method) if (c->getType() != vtbltype->getElementType(k)) c = llvm::ConstantExpr::getBitCast(c, vtbltype->getElementType(k)); @@ -636,8 +636,8 @@ void DtoConstInitClass(ClassDeclaration* cd) FuncDeclaration* fd = dsym->isFuncDeclaration(); assert(fd); DtoForceDeclareDsymbol(fd); - assert(fd->irFunc->func); - llvm::Constant* c = llvm::cast(fd->irFunc->func); + assert(gIR->irFunc[fd]->func); + llvm::Constant* c = llvm::cast(gIR->irFunc[fd]->func); // we have to bitcast, as the type created in ResolveClass expects a different this type c = llvm::ConstantExpr::getBitCast(c, iri->vtblTy->getContainedType(k)); @@ -783,9 +783,9 @@ DValue* DtoNewClass(TypeClass* tc, NewExp* newexp) LOG_SCOPE; size_t idx = 2; //idx += tc->sym->irStruct->interfaces.size(); - llvm::Value* nest = gIR->func()->decl->irFunc->nestedVar; + llvm::Value* nest = gIR->irFunc[gIR->func()->decl]->nestedVar; if (!nest) - nest = gIR->func()->decl->irFunc->thisVar; + nest = gIR->irFunc[gIR->func()->decl]->thisVar; assert(nest); llvm::Value* gep = DtoGEPi(mem,0,idx,"tmp"); nest = DtoBitCast(nest, gep->getType()->getContainedType(0)); @@ -851,7 +851,7 @@ DValue* DtoCallClassCtor(TypeClass* type, CtorDeclaration* ctor, Array* argument assert(ctor); DtoForceDeclareDsymbol(ctor); - llvm::Function* fn = ctor->irFunc->func; + llvm::Function* fn = gIR->irFunc[ctor]->func; TypeFunction* tf = (TypeFunction*)DtoDType(ctor->type); std::vector ctorargs; @@ -881,8 +881,8 @@ void DtoCallClassDtors(TypeClass* tc, llvm::Value* instance) for (size_t i=0; idim; i++) { FuncDeclaration* fd = (FuncDeclaration*)arr->data[i]; - assert(fd->irFunc->func); - new llvm::CallInst(fd->irFunc->func, instance, "", gIR->scopebb()); + assert(gIR->irFunc[fd]->func); + new llvm::CallInst(gIR->irFunc[fd]->func, instance, "", gIR->scopebb()); } } @@ -1300,8 +1300,8 @@ static llvm::Constant* build_class_dtor(ClassDeclaration* cd) else if (cd->dtors.dim == 1) { DtorDeclaration *d = (DtorDeclaration *)cd->dtors.data[0]; DtoForceDeclareDsymbol(d); - assert(d->irFunc->func); - return llvm::ConstantExpr::getBitCast(isaConstant(d->irFunc->func), getPtrToType(llvm::Type::Int8Ty)); + assert(gIR->irFunc[d]->func); + return llvm::ConstantExpr::getBitCast(isaConstant(gIR->irFunc[d]->func), getPtrToType(llvm::Type::Int8Ty)); } std::string gname("_D"); @@ -1319,8 +1319,8 @@ static llvm::Constant* build_class_dtor(ClassDeclaration* cd) { DtorDeclaration *d = (DtorDeclaration *)cd->dtors.data[i]; DtoForceDeclareDsymbol(d); - assert(d->irFunc->func); - builder.CreateCall(d->irFunc->func, thisptr); + assert(gIR->irFunc[d]->func); + builder.CreateCall(gIR->irFunc[d]->func, thisptr); } builder.CreateRetVoid(); @@ -1516,7 +1516,7 @@ void DtoDefineClassInfo(ClassDeclaration* cd) // default constructor if (cd->defaultCtor && !cd->isInterfaceDeclaration() && !cd->isAbstract()) { DtoForceDeclareDsymbol(cd->defaultCtor); - c = isaConstant(cd->defaultCtor->irFunc->func); + c = isaConstant(gIR->irFunc[cd->defaultCtor]->func); const llvm::Type* toTy = cinfo->irStruct->constInit->getOperand(12)->getType(); c = llvm::ConstantExpr::getBitCast(c, toTy); } diff --git a/gen/functions.cpp b/gen/functions.cpp index a56da516..76b5b406 100644 --- a/gen/functions.cpp +++ b/gen/functions.cpp @@ -232,7 +232,7 @@ static llvm::Function* DtoDeclareVaFunction(FuncDeclaration* fdecl) llvm::Function* func = llvm::dyn_cast(fn); assert(func); assert(func->isIntrinsic()); - fdecl->irFunc->func = func; + gIR->irFunc[fdecl]->func = func; return func; } @@ -311,9 +311,9 @@ void DtoDeclareFunction(FuncDeclaration* fdecl) if (fdecl->runTimeHack) { Logger::println("runtime hack func chars: %s", fdecl->toChars()); - if (!fdecl->irFunc) { - fdecl->irFunc = new IrFunction(fdecl); - fdecl->irFunc->func = LLVM_D_GetRuntimeFunction(gIR->module, fdecl->toChars()); + if (gIR->irFunc.find(fdecl) == gIR->irFunc.end()) { + gIR->irFunc[fdecl] = new IrFunction(fdecl); + gIR->irFunc[fdecl]->func = LLVM_D_GetRuntimeFunction(gIR->module, fdecl->toChars()); } return; } @@ -330,8 +330,8 @@ void DtoDeclareFunction(FuncDeclaration* fdecl) else if (fdecl->llvmInternal == LLVMva_start) declareOnly = true; - if (!fdecl->irFunc) { - fdecl->irFunc = new IrFunction(fdecl); + if (gIR->irFunc.find(fdecl) == gIR->irFunc.end()) { + gIR->irFunc[fdecl] = new IrFunction(fdecl); } // mangled name @@ -358,7 +358,7 @@ void DtoDeclareFunction(FuncDeclaration* fdecl) assert(func->getFunctionType() == functype); // add func to IRFunc - fdecl->irFunc->func = func; + gIR->irFunc[fdecl]->func = func; // calling convention if (!vafunc && fdecl->llvmInternal != LLVMintrinsic) @@ -366,7 +366,7 @@ void DtoDeclareFunction(FuncDeclaration* fdecl) else // fall back to C, it should be the right thing to do func->setCallingConv(llvm::CallingConv::C); - fdecl->irFunc->func = func; + gIR->irFunc[fdecl]->func = func; assert(llvm::isa(f->llvmType->get())); // main @@ -388,22 +388,22 @@ void DtoDeclareFunction(FuncDeclaration* fdecl) int k = 0; if (f->llvmRetInPtr) { iarg->setName("retval"); - fdecl->irFunc->retArg = iarg; + gIR->irFunc[fdecl]->retArg = iarg; ++iarg; } if (f->llvmUsesThis) { iarg->setName("this"); - fdecl->irFunc->thisVar = iarg; - assert(fdecl->irFunc->thisVar); + gIR->irFunc[fdecl]->thisVar = iarg; + assert(gIR->irFunc[fdecl]->thisVar); ++iarg; } if (f->linkage == LINKd && f->varargs == 1) { iarg->setName("_arguments"); - fdecl->irFunc->_arguments = iarg; + gIR->irFunc[fdecl]->_arguments = iarg; ++iarg; iarg->setName("_argptr"); - fdecl->irFunc->_argptr = iarg; + gIR->irFunc[fdecl]->_argptr = iarg; ++iarg; } @@ -457,14 +457,14 @@ void DtoDefineFunc(FuncDeclaration* fd) // debug info if (global.params.symdebug) { Module* mo = fd->getModule(); - fd->irFunc->dwarfSubProg = DtoDwarfSubProgram(fd, DtoDwarfCompileUnit(mo)); + gIR->irFunc[fd]->dwarfSubProg = DtoDwarfSubProgram(fd, DtoDwarfCompileUnit(mo)); } Type* t = DtoDType(fd->type); TypeFunction* f = (TypeFunction*)t; assert(f->llvmType); - llvm::Function* func = fd->irFunc->func; + llvm::Function* func = gIR->irFunc[fd]->func; const llvm::FunctionType* functype = func->getFunctionType(); // only members of the current module or template instances maybe be defined @@ -476,8 +476,8 @@ void DtoDefineFunc(FuncDeclaration* fd) if (fd->fbody != 0) { Logger::println("Doing function body for: %s", fd->toChars()); - assert(fd->irFunc); - gIR->functions.push_back(fd->irFunc); + assert(gIR->irFunc.count(fd) != 0); + gIR->functions.push_back(gIR->irFunc[fd]); if (fd->isMain()) gIR->emitMain = true; @@ -527,7 +527,7 @@ void DtoDefineFunc(FuncDeclaration* fd) llvm::Value* parentNested = NULL; if (FuncDeclaration* fd2 = fd->toParent2()->isFuncDeclaration()) { if (!fd->isStatic()) // huh? - parentNested = fd2->irFunc->nestedVar; + parentNested = gIR->irFunc[fd2]->nestedVar; } // need result variable? (nested) @@ -553,7 +553,7 @@ void DtoDefineFunc(FuncDeclaration* fd) if (vd->isParameter()) { if (!vd->irLocal->value) { assert(vd == fd->vthis); - vd->irLocal->value = fd->irFunc->thisVar; + vd->irLocal->value = gIR->irFunc[fd]->thisVar; } assert(vd->irLocal->value); nestTypes.push_back(vd->irLocal->value->getType()); @@ -564,18 +564,18 @@ void DtoDefineFunc(FuncDeclaration* fd) } const llvm::StructType* nestSType = llvm::StructType::get(nestTypes); Logger::cout() << "nested var struct has type:" << *nestSType << '\n'; - fd->irFunc->nestedVar = new llvm::AllocaInst(nestSType,"nestedvars",allocaPoint); + gIR->irFunc[fd]->nestedVar = new llvm::AllocaInst(nestSType,"nestedvars",allocaPoint); if (parentNested) { - assert(fd->irFunc->thisVar); - llvm::Value* ptr = gIR->ir->CreateBitCast(fd->irFunc->thisVar, parentNested->getType(), "tmp"); - gIR->ir->CreateStore(ptr, DtoGEPi(fd->irFunc->nestedVar, 0,0, "tmp")); + assert(gIR->irFunc[fd]->thisVar); + llvm::Value* ptr = gIR->ir->CreateBitCast(gIR->irFunc[fd]->thisVar, parentNested->getType(), "tmp"); + gIR->ir->CreateStore(ptr, DtoGEPi(gIR->irFunc[fd]->nestedVar, 0,0, "tmp")); } for (std::set::iterator i=fd->nestedVars.begin(); i!=fd->nestedVars.end(); ++i) { VarDeclaration* vd = *i; if (vd->isParameter()) { assert(vd->irLocal); - gIR->ir->CreateStore(vd->irLocal->value, DtoGEPi(fd->irFunc->nestedVar, 0, vd->irLocal->nestedIndex, "tmp")); - vd->irLocal->value = fd->irFunc->nestedVar; + gIR->ir->CreateStore(vd->irLocal->value, DtoGEPi(gIR->irFunc[fd]->nestedVar, 0, vd->irLocal->nestedIndex, "tmp")); + vd->irLocal->value = gIR->irFunc[fd]->nestedVar; } } } @@ -583,9 +583,9 @@ void DtoDefineFunc(FuncDeclaration* fd) // copy _argptr to a memory location if (f->linkage == LINKd && f->varargs == 1) { - llvm::Value* argptrmem = new llvm::AllocaInst(fd->irFunc->_argptr->getType(), "_argptrmem", gIR->topallocapoint()); - new llvm::StoreInst(fd->irFunc->_argptr, argptrmem, gIR->scopebb()); - fd->irFunc->_argptr = argptrmem; + llvm::Value* argptrmem = new llvm::AllocaInst(gIR->irFunc[fd]->_argptr->getType(), "_argptrmem", gIR->topallocapoint()); + new llvm::StoreInst(gIR->irFunc[fd]->_argptr, argptrmem, gIR->scopebb()); + gIR->irFunc[fd]->_argptr = argptrmem; } // output function body diff --git a/gen/irstate.h b/gen/irstate.h index e38ea1d3..660e5214 100644 --- a/gen/irstate.h +++ b/gen/irstate.h @@ -3,6 +3,7 @@ #include #include +#include #include "root.h" #include "aggregate.h" @@ -76,6 +77,8 @@ struct IRState typedef std::vector FunctionVector; FunctionVector functions; IrFunction* func(); + // ir data associated with function declarations + std::map irFunc; llvm::Function* topfunc(); TypeFunction* topfunctype(); diff --git a/gen/statements.cpp b/gen/statements.cpp index 3b50cc5b..66f2a277 100644 --- a/gen/statements.cpp +++ b/gen/statements.cpp @@ -77,11 +77,11 @@ void ReturnStatement::toIR(IRState* p) if (p->topfunc()->getReturnType() == llvm::Type::VoidTy) { IrFunction* f = p->func(); assert(f->type->llvmRetInPtr); - assert(f->decl->irFunc->retArg); + assert(gIR->irFunc[f->decl]->retArg); if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum); - DValue* rvar = new DVarValue(f->type->next, f->decl->irFunc->retArg, true); + DValue* rvar = new DVarValue(f->type->next, gIR->irFunc[f->decl]->retArg, true); p->exps.push_back(IRExp(NULL,exp,rvar)); DValue* e = exp->toElem(p); diff --git a/gen/todebug.cpp b/gen/todebug.cpp index c0b02b46..15a3fba9 100644 --- a/gen/todebug.cpp +++ b/gen/todebug.cpp @@ -182,14 +182,14 @@ llvm::GlobalVariable* DtoDwarfSubProgram(FuncDeclaration* fd, llvm::GlobalVariab void DtoDwarfFuncStart(FuncDeclaration* fd) { - assert(fd->irFunc->dwarfSubProg); - gIR->ir->CreateCall(gIR->module->getFunction("llvm.dbg.func.start"), dbgToArrTy(fd->irFunc->dwarfSubProg)); + assert(gIR->irFunc[fd]->dwarfSubProg); + gIR->ir->CreateCall(gIR->module->getFunction("llvm.dbg.func.start"), dbgToArrTy(gIR->irFunc[fd]->dwarfSubProg)); } void DtoDwarfFuncEnd(FuncDeclaration* fd) { - assert(fd->irFunc->dwarfSubProg); - gIR->ir->CreateCall(gIR->module->getFunction("llvm.dbg.region.end"), dbgToArrTy(fd->irFunc->dwarfSubProg)); + assert(gIR->irFunc[fd]->dwarfSubProg); + gIR->ir->CreateCall(gIR->module->getFunction("llvm.dbg.region.end"), dbgToArrTy(gIR->irFunc[fd]->dwarfSubProg)); } ////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/gen/toir.cpp b/gen/toir.cpp index 16930480..49c13ec9 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -62,7 +62,7 @@ DValue* DeclarationExp::toElem(IRState* p) if (vd->nestedref) { Logger::println("has nestedref set"); assert(vd->irLocal); - vd->irLocal->value = p->func()->decl->irFunc->nestedVar; + vd->irLocal->value = gIR->irFunc[p->func()->decl]->nestedVar; assert(vd->irLocal->value); assert(vd->irLocal->nestedIndex >= 0); } @@ -157,7 +157,7 @@ DValue* VarExp::toElem(IRState* p) vd->getIrValue() = p->func()->decl->irFunc->_arguments; assert(vd->getIrValue()); return new DVarValue(vd, vd->getIrValue(), true);*/ - llvm::Value* v = p->func()->decl->irFunc->_arguments; + llvm::Value* v = gIR->irFunc[p->func()->decl]->_arguments; assert(v); return new DVarValue(vd, v, true); } @@ -169,7 +169,7 @@ DValue* VarExp::toElem(IRState* p) vd->getIrValue() = p->func()->decl->irFunc->_argptr; assert(vd->getIrValue()); return new DVarValue(vd, vd->getIrValue(), true);*/ - llvm::Value* v = p->func()->decl->irFunc->_argptr; + llvm::Value* v = gIR->irFunc[p->func()->decl]->_argptr; assert(v); return new DVarValue(vd, v, true); } @@ -243,7 +243,7 @@ DValue* VarExp::toElem(IRState* p) if (fdecl->llvmInternal != LLVMva_arg) {// && fdecl->llvmValue == 0) DtoForceDeclareDsymbol(fdecl); } - return new DFuncValue(fdecl, fdecl->irFunc->func); + return new DFuncValue(fdecl, gIR->irFunc[fdecl]->func); } else if (SymbolDeclaration* sdecl = var->isSymbolDeclaration()) { @@ -1317,7 +1317,7 @@ DValue* AddrExp::toElem(IRState* p) FuncDeclaration* fd = fv->func; assert(fd); DtoForceDeclareDsymbol(fd); - return new DFuncValue(fd, fd->irFunc->func); + return new DFuncValue(fd, gIR->irFunc[fd]->func); } else if (DImValue* im = v->isIm()) { Logger::println("is immediate"); @@ -1422,7 +1422,7 @@ DValue* DotVarExp::toElem(IRState* p) // super call if (e1->op == TOKsuper) { DtoForceDeclareDsymbol(fdecl); - funcval = fdecl->irFunc->func; + funcval = gIR->irFunc[fdecl]->func; assert(funcval); } // normal virtual call @@ -1443,7 +1443,7 @@ DValue* DotVarExp::toElem(IRState* p) // static call else { DtoForceDeclareDsymbol(fdecl); - funcval = fdecl->irFunc->func; + funcval = gIR->irFunc[fdecl]->func; assert(funcval); //assert(funcval->getType() == DtoType(fdecl->type)); } @@ -1466,7 +1466,7 @@ DValue* ThisExp::toElem(IRState* p) if (VarDeclaration* vd = var->isVarDeclaration()) { llvm::Value* v; - v = p->func()->decl->irFunc->thisVar; + v = gIR->irFunc[p->func()->decl]->thisVar; if (llvm::isa(v)) v = new llvm::LoadInst(v, "tmp", p->scopebb()); return new DThisValue(vd, v); @@ -2216,7 +2216,7 @@ DValue* DelegateExp::toElem(IRState* p) if (DFuncValue* f = u->isFunc()) { //assert(f->vthis); //uval = f->vthis; - llvm::Value* nestvar = p->func()->decl->irFunc->nestedVar; + llvm::Value* nestvar = gIR->irFunc[p->func()->decl]->nestedVar; if (nestvar) uval = nestvar; else @@ -2256,7 +2256,7 @@ DValue* DelegateExp::toElem(IRState* p) else { DtoForceDeclareDsymbol(func); - castfptr = func->irFunc->func; + castfptr = gIR->irFunc[func]->func; } castfptr = DtoBitCast(castfptr, fptr->getType()->getContainedType(0)); @@ -2490,7 +2490,7 @@ DValue* FuncExp::toElem(IRState* p) llvm::Value* context = DtoGEPi(lval,0,0,"tmp",p->scopebb()); const llvm::PointerType* pty = isaPointer(context->getType()->getContainedType(0)); - llvm::Value* llvmNested = p->func()->decl->irFunc->nestedVar; + llvm::Value* llvmNested = gIR->irFunc[p->func()->decl]->nestedVar; if (llvmNested == NULL) { llvm::Value* nullcontext = llvm::ConstantPointerNull::get(pty); p->ir->CreateStore(nullcontext, context); @@ -2502,8 +2502,8 @@ DValue* FuncExp::toElem(IRState* p) llvm::Value* fptr = DtoGEPi(lval,0,1,"tmp",p->scopebb()); - assert(fd->irFunc->func); - llvm::Value* castfptr = new llvm::BitCastInst(fd->irFunc->func,fptr->getType()->getContainedType(0),"tmp",p->scopebb()); + assert(gIR->irFunc[fd]->func); + llvm::Value* castfptr = new llvm::BitCastInst(gIR->irFunc[fd]->func,fptr->getType()->getContainedType(0),"tmp",p->scopebb()); new llvm::StoreInst(castfptr, fptr, p->scopebb()); if (temp) diff --git a/gen/tollvm.cpp b/gen/tollvm.cpp index 9e874f1e..1a06d709 100644 --- a/gen/tollvm.cpp +++ b/gen/tollvm.cpp @@ -724,7 +724,7 @@ static const llvm::Type* get_next_frame_ptr_type(Dsymbol* sc) assert(p->isFuncDeclaration() || p->isClassDeclaration()); if (FuncDeclaration* fd = p->isFuncDeclaration()) { - llvm::Value* v = fd->irFunc->nestedVar; + llvm::Value* v = gIR->irFunc[fd]->nestedVar; assert(v); return v->getType(); } @@ -754,9 +754,9 @@ static llvm::Value* get_frame_ptr_impl(FuncDeclaration* func, Dsymbol* sc, llvm: if (fd->toParent2() == func) { - if (!func->irFunc->nestedVar) + if (!gIR->irFunc[func]->nestedVar) return NULL; - return DtoBitCast(v, func->irFunc->nestedVar->getType()); + return DtoBitCast(v, gIR->irFunc[func]->nestedVar->getType()); } v = DtoBitCast(v, get_next_frame_ptr_type(fd)); @@ -807,10 +807,10 @@ static llvm::Value* get_frame_ptr(FuncDeclaration* func) // in the right scope already if (func == irfunc->decl) - return irfunc->decl->irFunc->nestedVar; + return gIR->irFunc[irfunc->decl]->nestedVar; // use the 'this' pointer - llvm::Value* ptr = irfunc->decl->irFunc->thisVar; + llvm::Value* ptr = gIR->irFunc[irfunc->decl]->thisVar; assert(ptr); // return the fully resolved frame pointer @@ -878,7 +878,7 @@ llvm::Value* DtoNestedVariable(VarDeclaration* vd) assert(ptr && "nested var, but no context"); // we must cast here to be sure. nested classes just have a void* - ptr = DtoBitCast(ptr, func->irFunc->nestedVar->getType()); + ptr = DtoBitCast(ptr, gIR->irFunc[func]->nestedVar->getType()); // index nested var and load (if necessary) llvm::Value* v = DtoGEPi(ptr, 0, vd->irLocal->nestedIndex, "tmp"); @@ -964,9 +964,9 @@ void DtoAssign(DValue* lhs, DValue* rhs) llvm::Value* tmp = rhs->getRVal(); FuncDeclaration* fdecl = gIR->func()->decl; // respecify the this param - if (!llvm::isa(fdecl->irFunc->thisVar)) - fdecl->irFunc->thisVar = new llvm::AllocaInst(tmp->getType(), "newthis", gIR->topallocapoint()); - DtoStore(tmp, fdecl->irFunc->thisVar); + if (!llvm::isa(gIR->irFunc[fdecl]->thisVar)) + gIR->irFunc[fdecl]->thisVar = new llvm::AllocaInst(tmp->getType(), "newthis", gIR->topallocapoint()); + DtoStore(tmp, gIR->irFunc[fdecl]->thisVar); } // regular class ref -> class ref assignment else { diff --git a/gen/toobj.cpp b/gen/toobj.cpp index b9d92214..c52e6a5e 100644 --- a/gen/toobj.cpp +++ b/gen/toobj.cpp @@ -177,7 +177,7 @@ static llvm::Function* build_module_ctor() size_t n = gIR->ctors.size(); if (n == 1) - return gIR->ctors[0]->irFunc->func; + return gIR->irFunc[gIR->ctors[0]]->func; std::string name("_D"); name.append(gIR->dmodule->mangle()); @@ -192,7 +192,7 @@ static llvm::Function* build_module_ctor() LLVMBuilder builder(bb); for (size_t i=0; ictors[i]->irFunc->func; + llvm::Function* f = gIR->irFunc[gIR->ctors[i]]->func; llvm::CallInst* call = builder.CreateCall(f,""); call->setCallingConv(llvm::CallingConv::Fast); } @@ -210,7 +210,7 @@ static llvm::Function* build_module_dtor() size_t n = gIR->dtors.size(); if (n == 1) - return gIR->dtors[0]->irFunc->func; + return gIR->irFunc[gIR->dtors[0]]->func; std::string name("_D"); name.append(gIR->dmodule->mangle()); @@ -225,7 +225,7 @@ static llvm::Function* build_module_dtor() LLVMBuilder builder(bb); for (size_t i=0; idtors[i]->irFunc->func; + llvm::Function* f = gIR->irFunc[gIR->dtors[i]]->func; llvm::CallInst* call = builder.CreateCall(f,""); call->setCallingConv(llvm::CallingConv::Fast); } @@ -243,7 +243,7 @@ static llvm::Function* build_module_unittest() size_t n = gIR->unitTests.size(); if (n == 1) - return gIR->unitTests[0]->irFunc->func; + return gIR->irFunc[gIR->unitTests[0]]->func; std::string name("_D"); name.append(gIR->dmodule->mangle()); @@ -258,7 +258,7 @@ static llvm::Function* build_module_unittest() LLVMBuilder builder(bb); for (size_t i=0; iunitTests[i]->irFunc->func; + llvm::Function* f = gIR->irFunc[gIR->unitTests[i]]->func; llvm::CallInst* call = builder.CreateCall(f,""); call->setCallingConv(llvm::CallingConv::Fast); } diff --git a/gen/typinf.cpp b/gen/typinf.cpp index 3218294c..b5ed80bd 100644 --- a/gen/typinf.cpp +++ b/gen/typinf.cpp @@ -925,8 +925,8 @@ void TypeInfoStructDeclaration::llvmDefine() fd = fdx->overloadExactMatch(tftohash); if (fd) { DtoForceDeclareDsymbol(fd); - assert(fd->irFunc->func != 0); - llvm::Constant* c = isaConstant(fd->irFunc->func); + assert(gIR->irFunc[fd]->func != 0); + llvm::Constant* c = isaConstant(gIR->irFunc[fd]->func); assert(c); c = llvm::ConstantExpr::getBitCast(c, ptty); sinits.push_back(c); @@ -951,8 +951,8 @@ void TypeInfoStructDeclaration::llvmDefine() fd = fdx->overloadExactMatch(tfeqptr); if (fd) { DtoForceDeclareDsymbol(fd); - assert(fd->irFunc->func != 0); - llvm::Constant* c = isaConstant(fd->irFunc->func); + assert(gIR->irFunc[fd]->func != 0); + llvm::Constant* c = isaConstant(gIR->irFunc[fd]->func); assert(c); c = llvm::ConstantExpr::getBitCast(c, ptty); sinits.push_back(c); @@ -979,8 +979,8 @@ void TypeInfoStructDeclaration::llvmDefine() fd = fdx->overloadExactMatch(tftostring); if (fd) { DtoForceDeclareDsymbol(fd); - assert(fd->irFunc->func != 0); - llvm::Constant* c = isaConstant(fd->irFunc->func); + assert(gIR->irFunc[fd]->func != 0); + llvm::Constant* c = isaConstant(gIR->irFunc[fd]->func); assert(c); c = llvm::ConstantExpr::getBitCast(c, ptty); sinits.push_back(c);