From e95466cb642284bb166cc2bc073d8da1a3cad3e3 Mon Sep 17 00:00:00 2001 From: Tomas Lindquist Olsen Date: Mon, 1 Oct 2007 21:19:53 +0200 Subject: [PATCH] [svn r13] * Updated for LLVM 2.1 * Class v-tables are now typesafe * Code cleanups --- dmd/declaration.h | 3 - dmd/mars.c | 3 +- dmd/mtype.c | 1 + dmd/mtype.h | 1 + gen/toir.c | 6 +- gen/tollvm.c | 90 ++++++++++++- gen/tollvm.h | 1 + gen/toobj.c | 334 ++++++++++++++-------------------------------- lib/llvmdcore.bc | Bin 3976 -> 3968 bytes lphobos/build.sh | 8 +- test/classes6.d | 15 +++ test/funcs2.d | 9 ++ 12 files changed, 222 insertions(+), 249 deletions(-) create mode 100644 test/classes6.d create mode 100644 test/funcs2.d diff --git a/dmd/declaration.h b/dmd/declaration.h index 87c20df9..83da7b2b 100644 --- a/dmd/declaration.h +++ b/dmd/declaration.h @@ -126,9 +126,6 @@ struct Declaration : Dsymbol Declaration *isDeclaration() { return this; } virtual void toObjFile(); // compile to .obj file - - // llvm stuff - llvm::Value* llvmValue; }; /**************************************************************/ diff --git a/dmd/mars.c b/dmd/mars.c index 96cca884..05ed7748 100644 --- a/dmd/mars.c +++ b/dmd/mars.c @@ -158,7 +158,8 @@ void usage() printf("LLVM D Compiler %s (based on DMD %s)\n%s\n%s\n", global.llvmdc_version, global.version, global.copyright, global.written); printf("\ -Documentation: http://www.digitalmars.com/d/1.0/index.html\n\ +D Language Documentation: http://www.digitalmars.com/d/1.0/index.html\n\ +LLVMDC Homepage: http://www.dsource.org/projects/llvmdc\n\ Usage:\n\ dmd files.d ... { -switch }\n\ \n\ diff --git a/dmd/mtype.c b/dmd/mtype.c index c3510a8e..f27395e4 100644 --- a/dmd/mtype.c +++ b/dmd/mtype.c @@ -2541,6 +2541,7 @@ TypeFunction::TypeFunction(Arguments *parameters, Type *treturn, int varargs, en this->linkage = linkage; this->inuse = 0; this->llvmRetInPtr = false; + this->llvmUsesThis = false; this->llvmRetArg = 0; this->llvmAllocaPoint = 0; } diff --git a/dmd/mtype.h b/dmd/mtype.h index 67b8e022..2200e34c 100644 --- a/dmd/mtype.h +++ b/dmd/mtype.h @@ -433,6 +433,7 @@ struct TypeFunction : Type unsigned totym(); bool llvmRetInPtr; + bool llvmUsesThis; llvm::Value* llvmRetArg; llvm::Instruction* llvmAllocaPoint; }; diff --git a/gen/toir.c b/gen/toir.c index bddbe1b9..3b985a35 100644 --- a/gen/toir.c +++ b/gen/toir.c @@ -1246,16 +1246,14 @@ elem* DotVarExp::toElem(IRState* p) assert(fdecl->vtblIndex > 0); assert(e1->type->ty == Tclass); - const llvm::Type* vtbltype = llvm::PointerType::get(llvm::ArrayType::get(llvm::PointerType::get(llvm::Type::Int8Ty),0)); - llvm::Value* zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0, false); llvm::Value* vtblidx = llvm::ConstantInt::get(llvm::Type::Int32Ty, (size_t)fdecl->vtblIndex, false); funcval = LLVM_DtoGEP(e->arg, zero, zero, "tmp", p->scopebb()); funcval = new llvm::LoadInst(funcval,"tmp",p->scopebb()); - funcval = new llvm::BitCastInst(funcval, vtbltype, "tmp", p->scopebb()); funcval = LLVM_DtoGEP(funcval, zero, vtblidx, "tmp", p->scopebb()); funcval = new llvm::LoadInst(funcval,"tmp",p->scopebb()); - funcval = new llvm::BitCastInst(funcval, fdecl->llvmValue->getType(), "tmp", p->scopebb()); + assert(funcval->getType() == fdecl->llvmValue->getType()); + //funcval = new llvm::BitCastInst(funcval, fdecl->llvmValue->getType(), "tmp", p->scopebb()); } e->val = funcval; e->type = elem::VAL; diff --git a/gen/tollvm.c b/gen/tollvm.c index b4e094a7..1341ade3 100644 --- a/gen/tollvm.c +++ b/gen/tollvm.c @@ -208,7 +208,7 @@ llvm::FunctionType* LLVM_DtoFunctionType(FuncDeclaration* fdecl) TypeFunction* f = (TypeFunction*)fdecl->type; assert(f != 0); - // has already been pulled in by a reference to ( + // type has already been resolved if (f->llvmType != 0) { return llvm::cast(f->llvmType); } @@ -247,10 +247,17 @@ llvm::FunctionType* LLVM_DtoFunctionType(FuncDeclaration* fdecl) paramvec.push_back(rettype); } - if (fdecl->needThis() && fdecl->vthis) { - Logger::print("this is: %s\n", fdecl->vthis->type->toChars()); - paramvec.push_back(LLVM_DtoType(fdecl->vthis->type)); - usesthis = true; + if (fdecl->needThis()) { + if (AggregateDeclaration* ad = fdecl->isMember()) { + Logger::print("isMember = this is: %s\n", ad->type->toChars()); + const llvm::Type* thisty = LLVM_DtoType(ad->type); + if (llvm::isa(thisty)) + thisty = llvm::PointerType::get(thisty); + paramvec.push_back(thisty); + usesthis = true; + } + else + assert(0); } size_t n = Argument::dim(f->parameters); @@ -295,6 +302,8 @@ llvm::FunctionType* LLVM_DtoFunctionType(FuncDeclaration* fdecl) llvm::FunctionType* functype = llvm::FunctionType::get(actualRettype, paramvec, isvararg); f->llvmType = functype; + f->llvmRetInPtr = retinptr; + f->llvmUsesThis = usesthis; return functype; } @@ -837,3 +846,74 @@ llvm::Value* LLVM_DtoGEP(llvm::Value* ptr, const std::vector& src, con Logger::cout() << '\n'; return new llvm::GetElementPtrInst(ptr, dst.begin(), dst.end(), var, bb); } + +llvm::Function* LLVM_DtoDeclareFunction(FuncDeclaration* fdecl) +{ + if (fdecl->llvmValue != 0) { + return llvm::cast(fdecl->llvmValue); + } + + static int fdi = 0; + Logger::print("FuncDeclaration::toObjFile(%d,%s): %s\n", fdi++, fdecl->needThis()?"this":"static",fdecl->toChars()); + LOG_SCOPE; + + if (fdecl->llvmInternal == LLVMintrinsic && fdecl->fbody) { + error("intrinsics cannot have function bodies"); + fatal(); + } + + // construct function + TypeFunction* f = (TypeFunction*)fdecl->type; + assert(f != 0); + llvm::FunctionType* functype = (f->llvmType == 0) ? LLVM_DtoFunctionType(fdecl) : llvm::cast(f->llvmType); + + // mangled name + char* mangled_name = (fdecl->llvmInternal == LLVMintrinsic) ? fdecl->llvmInternal1 : fdecl->mangle(); + + // make the function + llvm::Function* func = gIR->module->getFunction(mangled_name); + if (func == 0) { + func = new llvm::Function(functype,LLVM_DtoLinkage(fdecl->protection, fdecl->storage_class),mangled_name,gIR->module); + } + + if (fdecl->llvmInternal != LLVMintrinsic) + func->setCallingConv(LLVM_DtoCallingConv(f->linkage)); + + fdecl->llvmValue = func; + f->llvmType = functype; + + if (fdecl->isMain()) { + gIR->mainFunc = func; + } + + // name parameters + llvm::Function::arg_iterator iarg = func->arg_begin(); + int k = 0; + if (f->llvmRetInPtr) { + iarg->setName("retval"); + f->llvmRetArg = iarg; + ++iarg; + } + if (f->llvmUsesThis) { + iarg->setName("this"); + ++iarg; + } + for (; iarg != func->arg_end(); ++iarg) + { + Argument* arg = Argument::getNth(f->parameters, k++); + assert(arg != 0); + //arg->llvmValue = iarg; + //printf("identifier: '%s' %p\n", arg->ident->toChars(), arg->ident); + if (arg->ident != 0) { + if (arg->vardecl) { + arg->vardecl->llvmValue = iarg; + } + iarg->setName(arg->ident->toChars()); + } + else { + iarg->setName("unnamed"); + } + } + + return func; +} diff --git a/gen/tollvm.h b/gen/tollvm.h index 89017522..38a54bcb 100644 --- a/gen/tollvm.h +++ b/gen/tollvm.h @@ -11,6 +11,7 @@ llvm::Constant* LLVM_DtoStructInitializer(StructInitializer* si); llvm::FunctionType* LLVM_DtoFunctionType(Type* t, const llvm::Type* thisparam = 0); llvm::FunctionType* LLVM_DtoFunctionType(FuncDeclaration* fdecl); +llvm::Function* LLVM_DtoDeclareFunction(FuncDeclaration* fdecl); llvm::StructType* LLVM_DtoDelegateType(Type* t); llvm::Value* LLVM_DtoNullDelegate(llvm::Value* v); diff --git a/gen/toobj.c b/gen/toobj.c index aa20a9b6..155336a7 100644 --- a/gen/toobj.c +++ b/gen/toobj.c @@ -336,7 +336,8 @@ void ClassDeclaration::toObjFile() gIR->queueClassMethods.push_back(true); // add vtable - const llvm::Type* vtabty = llvm::PointerType::get(llvm::Type::Int8Ty); + llvm::PATypeHolder pa = llvm::OpaqueType::get(); + const llvm::Type* vtabty = llvm::PointerType::get(pa); gIR->topstruct().fields.push_back(vtabty); gIR->topstruct().inits.push_back(0); @@ -361,18 +362,99 @@ void ClassDeclaration::toObjFile() ts->llvmType = structtype; llvmType = structtype; - bool emit_vtable = false; bool define_vtable = false; if (parent->isModule()) { gIR->module->addTypeName(mangle(),ts->llvmType); - emit_vtable = true; define_vtable = (getModule() == gIR->dmodule); } else { assert(0 && "class parent is not a module"); } - // generate member functions + // generate vtable + llvm::GlobalVariable* svtblVar = 0; + std::vector sinits; + std::vector sinits_ty; + sinits.reserve(vtbl.dim); + sinits_ty.reserve(vtbl.dim); + + for (int k=0; k < vtbl.dim; k++) + { + Dsymbol* dsym = (Dsymbol*)vtbl.data[k]; + assert(dsym); + //Logger::cout() << "vtblsym: " << dsym->toChars() << '\n'; + + if (FuncDeclaration* fd = dsym->isFuncDeclaration()) { + fd->toObjFile(); + llvm::Constant* c = llvm::cast(fd->llvmValue); + sinits.push_back(c); + sinits_ty.push_back(c->getType()); + } + else if (ClassDeclaration* cd = dsym->isClassDeclaration()) { + const llvm::Type* cty = llvm::PointerType::get(llvm::Type::Int8Ty); + llvm::Constant* c = llvm::Constant::getNullValue(cty); + sinits.push_back(c); + sinits_ty.push_back(cty); + } + else + assert(0); + } + + const llvm::StructType* svtbl_ty = 0; + if (!sinits.empty()) + { + llvm::GlobalValue::LinkageTypes _linkage = llvm::GlobalValue::ExternalLinkage; + + std::string varname(mangle()); + varname.append("__vtblZ"); + std::string styname(mangle()); + styname.append("__vtblTy"); + + svtbl_ty = llvm::StructType::get(sinits_ty); + gIR->module->addTypeName(styname, svtbl_ty); + svtblVar = new llvm::GlobalVariable(svtbl_ty, true, _linkage, 0, varname, gIR->module); + + if (define_vtable) { + svtblVar->setInitializer(llvm::ConstantStruct::get(svtbl_ty, sinits)); + } + llvmVtbl = svtblVar; + } + + //////////////////////////////////////////////////////////////////////////////// + + // refine for final vtable type + llvm::cast(pa.get())->refineAbstractTypeTo(svtbl_ty); + svtbl_ty = llvm::cast(pa.get()); + structtype = llvm::cast(gIR->topstruct().recty.get()); + ts->llvmType = structtype; + llvmType = structtype; + + // generate initializer + llvm::GlobalValue::LinkageTypes _linkage = llvm::GlobalValue::ExternalLinkage; + llvm::Constant* _init = 0; + + // first field is always the vtable + assert(svtblVar != 0); + gIR->topstruct().inits[0] = svtblVar; + + //assert(tk == gIR->topstruct().size()); + #ifndef LLVMD_NO_LOGGER + Logger::cout() << *structtype << '\n'; + //for (size_t k=0; ktopstruct().inits.size(); ++k) + // Logger::cout() << *gIR->topstruct().inits[k] << '\n'; + #endif + _init = llvm::ConstantStruct::get(structtype,gIR->topstruct().inits); + assert(_init); + std::string initname(mangle()); + initname.append("__initZ"); + Logger::cout() << *_init << '\n'; + llvm::GlobalVariable* initvar = new llvm::GlobalVariable(ts->llvmType, true, _linkage, 0, initname, gIR->module); + ts->llvmInit = initvar; + if (define_vtable) { + initvar->setInitializer(_init); + } + + // generate member function definitions gIR->queueClassMethods.back() = false; IRState::FuncDeclVec& mfs = gIR->classmethods.back(); size_t n = mfs.size(); @@ -380,76 +462,6 @@ void ClassDeclaration::toObjFile() mfs[i]->toObjFile(); } - // create vtable initializer - if (emit_vtable) - { - llvm::GlobalVariable* vtblVar = 0; - std::vector inits; - inits.reserve(vtbl.dim); - for (int k=0; k < vtbl.dim; k++) - { - Dsymbol* dsym = (Dsymbol*)vtbl.data[k]; - assert(dsym); - //Logger::cout() << "vtblsym: " << dsym->toChars() << '\n'; - - if (FuncDeclaration* fd = dsym->isFuncDeclaration()) { - fd->toObjFile(); - Logger::cout() << "casting to constant" << *fd->llvmValue << '\n'; - llvm::Constant* c = llvm::cast(fd->llvmValue); - c = llvm::ConstantExpr::getBitCast(c, llvm::PointerType::get(llvm::Type::Int8Ty)); - inits.push_back(c); - } - else if (ClassDeclaration* cd = dsym->isClassDeclaration()) { - llvm::Constant* c = llvm::Constant::getNullValue(llvm::PointerType::get(llvm::Type::Int8Ty)); - inits.push_back(c); - } - else - assert(0); - } - if (!inits.empty()) - { - llvm::GlobalValue::LinkageTypes _linkage = llvm::GlobalValue::ExternalLinkage; - std::string varname(mangle()); - varname.append("__vtblZ"); - const llvm::ArrayType* vtbl_ty = llvm::ArrayType::get(llvm::PointerType::get(llvm::Type::Int8Ty), inits.size()); - vtblVar = new llvm::GlobalVariable(vtbl_ty, true, _linkage, 0, varname, gIR->module); - if (define_vtable) { - //Logger::cout() << "vtbl:::" << '\n' << *vtbl_st << '\n';// << " == | == " << _init << '\n'; - llvm::Constant* _init = llvm::ConstantArray::get(vtbl_ty, inits); - vtblVar->setInitializer(_init); - } - llvmVtbl = vtblVar; - } - - //////////////////////////////////////////////////////////////////////////////// - - // generate initializer - llvm::GlobalValue::LinkageTypes _linkage = llvm::GlobalValue::ExternalLinkage; - llvm::Constant* _init = 0; - - // first field is always the vtable - assert(vtblVar != 0); - llvm::Constant* vtbl_init_var = llvm::ConstantExpr::getBitCast(vtblVar, llvm::PointerType::get(llvm::Type::Int8Ty)); - gIR->topstruct().inits[0] = vtbl_init_var; - - //assert(tk == gIR->topstruct().size()); - #ifndef LLVMD_NO_LOGGER - Logger::cout() << *structtype << '\n'; - for (size_t k=0; ktopstruct().inits.size(); ++k) - Logger::cout() << *gIR->topstruct().inits[k] << '\n'; - #endif - _init = llvm::ConstantStruct::get(structtype,gIR->topstruct().inits); - assert(_init); - std::string initname(mangle()); - initname.append("__initZ"); - Logger::cout() << *_init << '\n'; - llvm::GlobalVariable* initvar = new llvm::GlobalVariable(ts->llvmType, true, _linkage, 0, initname, gIR->module); - ts->llvmInit = initvar; - if (define_vtable) { - initvar->setInitializer(_init); - } - } - gIR->queueClassMethods.pop_back(); gIR->classmethods.pop_back(); gIR->classes.pop_back(); @@ -560,6 +572,8 @@ void VarDeclaration::toObjFile() else if (llvm::isa(_type)) { const llvm::StructType* structty = llvm::cast(_type); TypeStruct* ts = (TypeStruct*)type; + assert(ts); + assert(ts->sym); assert(ts->sym->llvmInitZ); _init = ts->sym->llvmInitZ; } @@ -594,11 +608,13 @@ void EnumDeclaration::toObjFile() void FuncDeclaration::toObjFile() { - if (llvmValue != 0 && llvmDModule == gIR->dmodule) { + if (llvmDModule == gIR->dmodule) { + assert(llvmValue != 0); return; } - // has already been pulled in by a reference to ( + llvm::Function* func = LLVM_DtoDeclareFunction(this); + if (!gIR->queueClassMethods.empty() && gIR->queueClassMethods.back()) { Logger::println("queueing %s", toChars()); assert(!gIR->classmethods.empty()); @@ -606,160 +622,11 @@ void FuncDeclaration::toObjFile() return; // will be generated later when the this parameter has a type } - static int fdi = 0; - Logger::print("FuncDeclaration::toObjFile(%d,%s): %s\n", fdi++, needThis()?"this":"static",toChars()); - LOG_SCOPE; - - if (llvmInternal == LLVMintrinsic && fbody) { - error("intrinsics cannot have function bodies"); - fatal(); - } + if (llvmNeedsDefinition) + { TypeFunction* f = (TypeFunction*)type; - assert(f != 0); - - // return value type - const llvm::Type* rettype; - const llvm::Type* actualRettype; - Type* rt = f->next; - bool retinptr = false; - bool usesthis = false; - - if (isMain()) { - rettype = llvm::Type::Int32Ty; - actualRettype = rettype; - gIR->emitMain = true; - } - else if (rt) { - if (rt->ty == Tstruct || rt->ty == Tdelegate || rt->ty == Tarray) { - rettype = llvm::PointerType::get(LLVM_DtoType(rt)); - actualRettype = llvm::Type::VoidTy; - f->llvmRetInPtr = retinptr = true; - } - else { - rettype = LLVM_DtoType(rt); - actualRettype = rettype; - } - } - else { - assert(0); - } - - // parameter types - std::vector paramvec; - - if (retinptr) { - Logger::print("returning through pointer parameter\n"); - paramvec.push_back(rettype); - } - - if (needThis()) { - if (AggregateDeclaration* ad = isMember()) { - Logger::print("isMember = this is: %s\n", ad->type->toChars()); - const llvm::Type* thisty = LLVM_DtoType(ad->type); - if (llvm::isa(thisty)) - thisty = llvm::PointerType::get(thisty); - paramvec.push_back(thisty); - usesthis = true; - } - else - assert(0); - } - - size_t n = Argument::dim(f->parameters); - for (int i=0; i < n; ++i) { - Argument* arg = Argument::getNth(f->parameters, i); - // ensure scalar - Type* argT = arg->type; - assert(argT); - - if ((arg->storageClass & STCref) || (arg->storageClass & STCout)) { - //assert(arg->vardecl); - //arg->vardecl->refparam = true; - } - else - arg->llvmCopy = true; - - const llvm::Type* at = LLVM_DtoType(argT); - if (llvm::isa(at)) { - Logger::println("struct param"); - paramvec.push_back(llvm::PointerType::get(at)); - } - else if (llvm::isa(at)) { - Logger::println("sarray param"); - assert(argT->ty == Tsarray); - //paramvec.push_back(llvm::PointerType::get(at->getContainedType(0))); - paramvec.push_back(llvm::PointerType::get(at)); - } - else { - if (!arg->llvmCopy) { - Logger::println("ref param"); - at = llvm::PointerType::get(at); - } - else { - Logger::println("in param"); - } - paramvec.push_back(at); - } - } - - // construct function - bool isvararg = f->varargs; - llvm::FunctionType* functype = llvm::FunctionType::get(actualRettype, paramvec, isvararg); - - // mangled name - char* mangled_name = (llvmInternal == LLVMintrinsic) ? llvmInternal1 : mangle(); - llvm::Function* func = gIR->module->getFunction(mangled_name); - - // make the function - /*if (func != 0) { - llvmValue = func; - f->llvmType = functype; - return; // already pulled in from a forward declaration - } - else */ - if (func == 0) { - func = new llvm::Function(functype,LLVM_DtoLinkage(protection, storage_class),mangled_name,gIR->module); - } - - if (llvmInternal != LLVMintrinsic) - func->setCallingConv(LLVM_DtoCallingConv(f->linkage)); - - llvmValue = func; - f->llvmType = functype; - - if (isMain()) { - gIR->mainFunc = func; - } - - // name parameters - llvm::Function::arg_iterator iarg = func->arg_begin(); - int k = 0; - int nunnamed = 0; - if (retinptr) { - iarg->setName("retval"); - f->llvmRetArg = iarg; - ++iarg; - } - if (usesthis) { - iarg->setName("this"); - ++iarg; - } - for (; iarg != func->arg_end(); ++iarg) - { - Argument* arg = Argument::getNth(f->parameters, k++); - //arg->llvmValue = iarg; - //printf("identifier: '%s' %p\n", arg->ident->toChars(), arg->ident); - if (arg->ident != 0) { - if (arg->vardecl) { - arg->vardecl->llvmValue = iarg; - } - iarg->setName(arg->ident->toChars()); - } - else { - ++nunnamed; - } - } + llvm::FunctionType* functype = llvm::cast(f->llvmType); // only members of the current module maybe be defined if (getModule() == gIR->dmodule) @@ -796,7 +663,9 @@ void FuncDeclaration::toObjFile() // function definition if (allow_fbody && fbody != 0) { - assert(nunnamed == 0); + if (isMain()) + gIR->emitMain = true; + gIR->funcs.push(func); gIR->functypes.push(f); @@ -832,18 +701,19 @@ void FuncDeclaration::toObjFile() gIR->funcs.pop(); // get rid of the endentry block, it's never used + assert(!func->getBasicBlockList().empty()); func->getBasicBlockList().pop_back(); // if the last block is empty now, it must be unreachable or it's a bug somewhere else + // would be nice to figure out how to assert that this is correct llvm::BasicBlock* lastbb = &func->getBasicBlockList().back(); if (lastbb->empty()) { + // possibly assert(lastbb->getNumPredecessors() == 0); ??? try it out sometime ... new llvm::UnreachableInst(lastbb); } } } - else - { - Logger::println("only declaration"); + } llvmDModule = gIR->dmodule; diff --git a/lib/llvmdcore.bc b/lib/llvmdcore.bc index d2c009ceda50856977163489ee77ba6d86cee036..04c9615edc204902616aac3d1f82b1db38943dfd 100644 GIT binary patch literal 3968 zcmeHJdr(tX8b2YIdqcRu4dHRaLvIpFQ%c*LOXRV*l7xuCrfhgPb!T*%1hj6gRvv>4 z+wR^#2$YQyfu&)@HY={$9lK*|wX3_c5=k9=U|p~-Q`#=p%9h=!V}-HZu?&084QT9k zru)y%{^OZ@?{^;G^LM`contH>`cz2*@QD}z5d{Ez0O3^cF^piPIK>roi(KR*krKr+ z>{kvxZFPjPJKFd;#Urr2iP!`CsBkUR=eRm+jrv|MBEqsbDgHAtOQW#;i?*__@PdfC;DU_R=Q+<>s z(urA2Z&(|@$I+0XykRaWim2#%IXI|NoHN9Y$#%b}dwh7vrg6R_Id6~ww^0+-YD~l< z)j-;2H3Ao>k;A!YzC_jwshYnKnI`>BFTnH0G_E=k7%&V{=c7QqY?o2<81IQnYqN5o zEuJ~=*EM;p6Z9Zxc4hsV(?q*vyo!#8;Q%@N@{qXjo5(_cYwlrU=XzpiQ~S?%wCCE| z8+Noe54Gp!6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UT)kB~!8I$!h7QSpr0Mncq3`2(Nvl^h0mxm7x+xJJ$0mY1w7e+x zItUg9j{}FiDaple;%l!1tV(x47o)h#iaeGMz2L7?7i~~p3V+M>SMFS{zbnl-_F3vD z1+X>zC2Xk{-#~?U5EbGH)G}%(O&U$}@54nJ%_oPs#<5E~?8_KjE#?{}=lfH9XnKkd z%)fka{{MV<9>!-m?|~3U{ni%czQ|l!L+)jk#+L-q6(z_b_qg%Bx_y8QHl_P00=C6y z!ZWQqS1bcMqTGdNk>!Zt7dnUhGo9!t_ z|AsG!)3;PhkY6Qo9#=n*?v7SL5S=UXP=1AE4~!Gqi{jtuj93*iSGcVpx_*l2jx89UD$Ir(sVfhO~ zAx1H~kW*_~yiJc7jbT$c1$Bv+>?R`?f4*|q`^8M2i@Mm|1$7quI_2X!Y3F2boh?Tq zKK`@6KT`W?;qm(UgM$)y#LRBU+@2{OHBG0y9HUtn+DDCjlFC0%eZ-`-lt{)hzr!^P z&IEJNgOD~!ZZ>3Coj>xJK|bksT-$~;6&*R9k}yp@HZt?w+qnKQxj1F^8YYJ3LNck1 zU|ucKF8tw3(DssP@&2Z*vz(`yro8CwgyOrm?_n??TpYd*q)mBsZz!1q9H}sT6Ou{i z8WR<^F68FeBGfa|Vab4A)UVYo-baDT9Hqya$E$VJO07bt-Yg!K2WiFPzE00$e7s*{ z^k*JS@+Uv*U+1ste)X*dKa(D`4dp?d(xJi t^q<~1$tC(g(#y$HU!ma7Eq*GEKle)G6N$T*5i#4j`V8lt6J8T;{S(0HmdOAB diff --git a/lphobos/build.sh b/lphobos/build.sh index 2a54537f..4ee5636b 100755 --- a/lphobos/build.sh +++ b/lphobos/build.sh @@ -1,7 +1,7 @@ #!/bin/bash if [ "$1" = "gdb" ]; then -dc_cmd="gdb --args llvmdmd" +dc_cmd="gdb --args llvmdc" else dc_cmd="llvmdc" fi @@ -11,11 +11,11 @@ $dc_cmd internal/contract.d \ internal/moduleinit.d \ -c -noruntime -odobj || exit 1 -$dc_cmd internal/objectimpl.d -c -odobj || exit 1 - llvm-as -f -o=obj/moduleinit_backend.bc internal/moduleinit_backend.ll || exit 1 +llvm-link -f -o=../lib/llvmdcore.bc obj/contract.bc obj/arrays.bc obj/moduleinit.bc obj/moduleinit_backend.bc || exit 1 -llvm-link -f -o=obj/all.bc obj/contract.bc obj/arrays.bc obj/moduleinit.bc obj/objectimpl.bc obj/moduleinit_backend.bc || return 1 +$dc_cmd internal/objectimpl.d -c -odobj || exit 1 +llvm-link -f -o=obj/all.bc obj/contract.bc obj/arrays.bc obj/moduleinit.bc obj/objectimpl.bc obj/moduleinit_backend.bc || exit 1 opt -f -std-compile-opts -o=../lib/llvmdcore.bc obj/all.bc || exit 1 diff --git a/test/classes6.d b/test/classes6.d new file mode 100644 index 00000000..9994e5a0 --- /dev/null +++ b/test/classes6.d @@ -0,0 +1,15 @@ +module classes6; + +class C +{ + void f() + { + printf("hello world\n"); + } +} + +void main() +{ + scope c = new C; + c.f(); +} diff --git a/test/funcs2.d b/test/funcs2.d new file mode 100644 index 00000000..5dcce3b7 --- /dev/null +++ b/test/funcs2.d @@ -0,0 +1,9 @@ +module funcs2; + +void func() +{ +} + +void main() +{ +}