comparison gen/toir.cpp @ 354:ac654d4cb935 trunk

[svn r375] Make DeclarationExp reuse storage if already allocated.
author ChristianK
date Mon, 14 Jul 2008 11:47:03 +0200
parents 6057fdf797d8
children 926f65e39246
comparison
equal deleted inserted replaced
353:a7a26f538d6e 354:ac654d4cb935
67 assert(vd->ir.irLocal); 67 assert(vd->ir.irLocal);
68 vd->ir.irLocal->value = p->func()->decl->ir.irFunc->nestedVar; 68 vd->ir.irLocal->value = p->func()->decl->ir.irFunc->nestedVar;
69 assert(vd->ir.irLocal->value); 69 assert(vd->ir.irLocal->value);
70 assert(vd->ir.irLocal->nestedIndex >= 0); 70 assert(vd->ir.irLocal->nestedIndex >= 0);
71 } 71 }
72 // normal stack variable 72 // normal stack variable, allocate storage on the stack if it has not already been done
73 else { 73 else if(!vd->ir.irLocal) {
74 // allocate storage on the stack
75 const LLType* lltype = DtoType(vd->type); 74 const LLType* lltype = DtoType(vd->type);
76 75
77 llvm::Value* allocainst; 76 llvm::Value* allocainst;
78 if(gTargetData->getTypeSizeInBits(lltype) == 0) 77 if(gTargetData->getTypeSizeInBits(lltype) == 0)
79 allocainst = llvm::ConstantPointerNull::get(getPtrToType(lltype)); 78 allocainst = llvm::ConstantPointerNull::get(getPtrToType(lltype));
80 else 79 else
81 allocainst = new llvm::AllocaInst(lltype, vd->toChars(), p->topallocapoint()); 80 allocainst = new llvm::AllocaInst(lltype, vd->toChars(), p->topallocapoint());
82 81
83 //allocainst->setAlignment(vd->type->alignsize()); // TODO 82 //allocainst->setAlignment(vd->type->alignsize()); // TODO
84 assert(!vd->ir.irLocal);
85 vd->ir.irLocal = new IrLocal(vd); 83 vd->ir.irLocal = new IrLocal(vd);
86 vd->ir.irLocal->value = allocainst; 84 vd->ir.irLocal->value = allocainst;
87 85
88 if (global.params.symdebug) 86 if (global.params.symdebug)
89 { 87 {