[svn r375] Make DeclarationExp reuse storage if already allocated.

This commit is contained in:
Christian Kamm
2008-07-14 11:47:03 +02:00
parent 7e7ac3a6f7
commit 65be990012
+2 -4
View File
@@ -69,9 +69,8 @@ DValue* DeclarationExp::toElem(IRState* p)
assert(vd->ir.irLocal->value);
assert(vd->ir.irLocal->nestedIndex >= 0);
}
// normal stack variable
else {
// allocate storage on the stack
// normal stack variable, allocate storage on the stack if it has not already been done
else if(!vd->ir.irLocal) {
const LLType* lltype = DtoType(vd->type);
llvm::Value* allocainst;
@@ -81,7 +80,6 @@ DValue* DeclarationExp::toElem(IRState* p)
allocainst = new llvm::AllocaInst(lltype, vd->toChars(), p->topallocapoint());
//allocainst->setAlignment(vd->type->alignsize()); // TODO
assert(!vd->ir.irLocal);
vd->ir.irLocal = new IrLocal(vd);
vd->ir.irLocal->value = allocainst;