diff --git a/gen/elem.c b/gen/elem.c index 05076790..6285d693 100644 --- a/gen/elem.c +++ b/gen/elem.c @@ -20,6 +20,7 @@ elem::elem() callconv = (unsigned)-1; isthis = false; istypeinfo = false; + temp = false; vardecl = 0; funcdecl = 0; diff --git a/gen/elem.h b/gen/elem.h index f5339c19..9882766a 100644 --- a/gen/elem.h +++ b/gen/elem.h @@ -33,6 +33,7 @@ public: unsigned callconv; bool isthis; bool istypeinfo; + bool temp; VarDeclaration* vardecl; FuncDeclaration* funcdecl; diff --git a/gen/toir.c b/gen/toir.c index 413b1d72..b82a33a8 100644 --- a/gen/toir.c +++ b/gen/toir.c @@ -362,9 +362,10 @@ elem* StringExp::toElem(IRState* p) if (dtype->ty == Tarray) { llvm::Constant* clen = llvm::ConstantInt::get(DtoSize_t(),len,false); if (!p->topexp() || p->topexp()->e2 != this) { - llvm::Value* tmpmem = new llvm::AllocaInst(DtoType(dtype),"tmp",p->topallocapoint()); + llvm::Value* tmpmem = new llvm::AllocaInst(DtoType(dtype),"tempstring",p->topallocapoint()); DtoSetArray(tmpmem, clen, arrptr); e->mem = tmpmem; + e->temp = true; } else if (p->topexp()->e2 == this) { llvm::Value* arr = p->topexp()->v; diff --git a/gen/tollvm.c b/gen/tollvm.c index e05b4ff8..053d9cc9 100644 --- a/gen/tollvm.c +++ b/gen/tollvm.c @@ -1196,6 +1196,9 @@ llvm::Value* DtoArgument(const llvm::Type* paramtype, Argument* fnarg, Expressio allocaInst = new llvm::AllocaInst(realtypell, "tmpparam", gIR->topallocapoint()); DtoSetArray(allocaInst, arg->arg, arg->mem); } + else if (arg->temp) { + allocaInst = arg->mem; + } else { allocaInst = new llvm::AllocaInst(pty->getElementType(), "tmpparam", gIR->topallocapoint()); DtoArrayAssign(allocaInst,arg->mem); @@ -1204,7 +1207,6 @@ llvm::Value* DtoArgument(const llvm::Type* paramtype, Argument* fnarg, Expressio else assert(0); - assert(allocaInst != 0); retval = allocaInst; } }