changeset 354:ac654d4cb935 trunk

[svn r375] Make DeclarationExp reuse storage if already allocated.
author ChristianK
date Mon, 14 Jul 2008 11:47:03 +0200
parents a7a26f538d6e
children d8357f7004ca
files gen/toir.cpp
diffstat 1 files changed, 2 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/gen/toir.cpp	Mon Jul 14 11:07:15 2008 +0200
+++ b/gen/toir.cpp	Mon Jul 14 11:47:03 2008 +0200
@@ -69,9 +69,8 @@
                 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 @@
                     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;