mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-17 05:13:14 +01:00
[svn r87] Fixed some memory bloat when passing string literals as char[] params (double temporary before)
This commit is contained in:
@@ -20,6 +20,7 @@ elem::elem()
|
||||
callconv = (unsigned)-1;
|
||||
isthis = false;
|
||||
istypeinfo = false;
|
||||
temp = false;
|
||||
|
||||
vardecl = 0;
|
||||
funcdecl = 0;
|
||||
|
||||
@@ -33,6 +33,7 @@ public:
|
||||
unsigned callconv;
|
||||
bool isthis;
|
||||
bool istypeinfo;
|
||||
bool temp;
|
||||
|
||||
VarDeclaration* vardecl;
|
||||
FuncDeclaration* funcdecl;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user