Mercurial > projects > ldc
changeset 27:92408a3a2bac trunk
[svn r31] * Fixed returning through hidden pointer was unable to report back the return value
* Fixed removed some litter instructions sometimes produced by constructor calls
author | lindquist |
---|---|
date | Thu, 04 Oct 2007 11:39:53 +0200 |
parents | 99737f94abfb |
children | 1c80c18f3c82 |
files | gen/toir.c gen/tollvm.c test/bug2.d |
diffstat | 3 files changed, 31 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/gen/toir.c Thu Oct 04 10:57:26 2007 +0200 +++ b/gen/toir.c Thu Oct 04 11:39:53 2007 +0200 @@ -976,7 +976,10 @@ // call the function llvm::CallInst* call = new llvm::CallInst(funcval, llargs.begin(), llargs.end(), varname, p->scopebb()); - e->val = call; + if (retinptr) + e->mem = llargs[0]; + else + e->val = call; // set calling convention if ((fn->funcdecl && (fn->funcdecl->llvmInternal != LLVMintrinsic)) || delegateCall) @@ -1812,13 +1815,14 @@ Expression* ex = (Expression*)arguments->data[i]; Logger::println("arg=%s", ex->toChars()); elem* exe = ex->toElem(p); - assert(exe->getValue()); - ctorargs.push_back(exe->getValue()); + llvm::Value* v = exe->getValue(); + assert(v); + ctorargs.push_back(v); delete exe; } assert(member); assert(member->llvmValue); - new llvm::CallInst(member->llvmValue, ctorargs.begin(), ctorargs.end(), "", p->scopebb()); + e->mem = new llvm::CallInst(member->llvmValue, ctorargs.begin(), ctorargs.end(), "tmp", p->scopebb()); } } else if (newtype->ty == Tstruct) {
--- a/gen/tollvm.c Thu Oct 04 10:57:26 2007 +0200 +++ b/gen/tollvm.c Thu Oct 04 11:39:53 2007 +0200 @@ -892,6 +892,25 @@ llvm::Function* LLVM_DtoDeclareFunction(FuncDeclaration* fdecl) { + // mangled name + char* mangled_name = (fdecl->llvmInternal == LLVMintrinsic) ? fdecl->llvmInternal1 : fdecl->mangle(); + + // unit test special handling + if (fdecl->isUnitTestDeclaration()) + { + assert(0 && "no unittests yet"); + /*const llvm::FunctionType* fnty = llvm::FunctionType::get(llvm::Type::VoidTy, std::vector<const llvm::Type*>(), false); + // make the function + llvm::Function* func = gIR->module->getFunction(mangled_name); + if (func == 0) + func = new llvm::Function(fnty,llvm::GlobalValue::InternalLinkage,mangled_name,gIR->module); + func->setCallingConv(llvm::CallingConv::Fast); + fdecl->llvmValue = func; + return func; + */ + } + + // regular function TypeFunction* f = (TypeFunction*)fdecl->type; assert(f != 0); @@ -915,9 +934,6 @@ // construct function const llvm::FunctionType* functype = (f->llvmType == 0) ? LLVM_DtoFunctionType(fdecl) : llvm::cast<llvm::FunctionType>(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) {