From 00072e5fd03427051705d5f60ae1c53e3cfdde4a Mon Sep 17 00:00:00 2001 From: Tomas Lindquist Olsen Date: Sat, 2 Aug 2008 21:51:49 +0200 Subject: [PATCH 1/2] Fixed debug info and lazy arguments. --- gen/functions.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gen/functions.cpp b/gen/functions.cpp index 87d12561..6cf3af17 100644 --- a/gen/functions.cpp +++ b/gen/functions.cpp @@ -595,8 +595,10 @@ void DtoDefineFunc(FuncDeclaration* fd) VarDeclaration* vd = argsym->isVarDeclaration(); assert(vd); + bool refoutlazy = vd->storage_class & (STCref | STCout | STClazy); + // FIXME: llvm seems to want an alloca/byval for debug info - if (!vd->needsStorage || vd->nestedref || vd->isRef() || vd->isOut()) + if (!vd->needsStorage || vd->nestedref || refoutlazy) { Logger::println("skipping arg storage for (%s) %s ", vd->loc.toChars(), vd->toChars()); continue; From 1ee9104354d17b30e44597cc64f986965d0d3ab6 Mon Sep 17 00:00:00 2001 From: Tomas Lindquist Olsen Date: Sat, 2 Aug 2008 22:35:24 +0200 Subject: [PATCH 2/2] Fixed AA Rvalue-only access (like indexing an AA return value immediately). --- gen/aa.cpp | 10 ++++++---- gen/aa.h | 2 +- gen/toir.cpp | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/gen/aa.cpp b/gen/aa.cpp index 9e5b4df6..f8eae571 100644 --- a/gen/aa.cpp +++ b/gen/aa.cpp @@ -66,17 +66,19 @@ static LLValue* to_keyti(DValue* key) ///////////////////////////////////////////////////////////////////////////////////// -DValue* DtoAAIndex(Loc& loc, Type* type, DValue* aa, DValue* key) +DValue* DtoAAIndex(Loc& loc, Type* type, DValue* aa, DValue* key, bool lvalue) { // call: - // extern(C) void* _aaGet(AA* aa, TypeInfo keyti, void* pkey, size_t valuesize) + // extern(C) void* _aaGet(AA* aa, TypeInfo keyti, size_t valuesize, void* pkey) + // or + // extern(C) void* _aaGetRvalue(AA aa, TypeInfo keyti, size_t valuesize, void* pkey) // first get the runtime function - llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, "_aaGet"); + llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, lvalue?"_aaGet":"_aaGetRvalue"); const llvm::FunctionType* funcTy = func->getFunctionType(); // aa param - LLValue* aaval = aa->getLVal(); + LLValue* aaval = lvalue ? aa->getLVal() : aa->getRVal(); aaval = DtoBitCast(aaval, funcTy->getParamType(0)); // keyti param diff --git a/gen/aa.h b/gen/aa.h index f9ababca..5afec0a5 100644 --- a/gen/aa.h +++ b/gen/aa.h @@ -1,7 +1,7 @@ #ifndef LLVMDC_GEN_AA_H #define LLVMDC_GEN_AA_H -DValue* DtoAAIndex(Loc& loc, Type* type, DValue* aa, DValue* key); +DValue* DtoAAIndex(Loc& loc, Type* type, DValue* aa, DValue* key, bool lvalue); DValue* DtoAAIn(Loc& loc, Type* type, DValue* aa, DValue* key); void DtoAARemove(Loc& loc, DValue* aa, DValue* key); diff --git a/gen/toir.cpp b/gen/toir.cpp index 51b72a03..e3c232c6 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -1034,7 +1034,7 @@ DValue* IndexExp::toElem(IRState* p) arrptr = DtoGEP1(arrptr,r->getRVal()); } else if (e1type->ty == Taarray) { - return DtoAAIndex(loc, type, l, r); + return DtoAAIndex(loc, type, l, r, modifiable); } else { Logger::println("invalid index exp! e1type: %s", e1type->toChars()); @@ -2255,7 +2255,7 @@ DValue* AssocArrayLiteralExp::toElem(IRState* p) // index DValue* key = ekey->toElem(p); - DValue* mem = DtoAAIndex(loc, vtype, aa, key); + DValue* mem = DtoAAIndex(loc, vtype, aa, key, true); // store DValue* val = eval->toElem(p);