[svn r171] starting to move IR data from AST nodes into IRState; started with IrFunction

This commit is contained in:
Christian Kamm
2008-04-29 21:33:50 +02:00
parent 12f62569cd
commit 48f1a9c507
11 changed files with 85 additions and 85 deletions
-2
View File
@@ -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<VarDeclaration*> nestedVars;
};
-1
View File
@@ -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)
+14 -14
View File
@@ -553,8 +553,8 @@ void DtoConstInitClass(ClassDeclaration* cd)
if (FuncDeclaration* fd = dsym->isFuncDeclaration()) {
DtoForceDeclareDsymbol(fd);
assert(fd->irFunc->func);
llvm::Constant* c = llvm::cast<llvm::Constant>(fd->irFunc->func);
assert(gIR->irFunc[fd]->func);
llvm::Constant* c = llvm::cast<llvm::Constant>(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<llvm::Constant>(fd->irFunc->func);
assert(gIR->irFunc[fd]->func);
llvm::Constant* c = llvm::cast<llvm::Constant>(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<llvm::Value*> ctorargs;
@@ -881,8 +881,8 @@ void DtoCallClassDtors(TypeClass* tc, llvm::Value* instance)
for (size_t i=0; i<arr->dim; 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);
}
+28 -28
View File
@@ -232,7 +232,7 @@ static llvm::Function* DtoDeclareVaFunction(FuncDeclaration* fdecl)
llvm::Function* func = llvm::dyn_cast<llvm::Function>(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<llvm::FunctionType>(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<VarDeclaration*>::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
+3
View File
@@ -3,6 +3,7 @@
#include <vector>
#include <list>
#include <map>
#include "root.h"
#include "aggregate.h"
@@ -76,6 +77,8 @@ struct IRState
typedef std::vector<IrFunction*> FunctionVector;
FunctionVector functions;
IrFunction* func();
// ir data associated with function declarations
std::map<FuncDeclaration*, IrFunction*> irFunc;
llvm::Function* topfunc();
TypeFunction* topfunctype();
+2 -2
View File
@@ -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);
+4 -4
View File
@@ -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));
}
//////////////////////////////////////////////////////////////////////////////////////////////////
+13 -13
View File
@@ -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<llvm::AllocaInst>(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)
+9 -9
View File
@@ -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<llvm::AllocaInst>(fdecl->irFunc->thisVar))
fdecl->irFunc->thisVar = new llvm::AllocaInst(tmp->getType(), "newthis", gIR->topallocapoint());
DtoStore(tmp, fdecl->irFunc->thisVar);
if (!llvm::isa<llvm::AllocaInst>(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 {
+6 -6
View File
@@ -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; i<n; i++) {
llvm::Function* f = gIR->ctors[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; i<n; i++) {
llvm::Function* f = gIR->dtors[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; i<n; i++) {
llvm::Function* f = gIR->unitTests[i]->irFunc->func;
llvm::Function* f = gIR->irFunc[gIR->unitTests[i]]->func;
llvm::CallInst* call = builder.CreateCall(f,"");
call->setCallingConv(llvm::CallingConv::Fast);
}
+6 -6
View File
@@ -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);