Mercurial > projects > ldc
diff gen/functions.cpp @ 1350:15e9762bb620
Adds explicit alignment information for alloca instructions in general, there's a few cases that still needs to be looked at but this should catch the majority. Fixes ticket #293 .
author | Tomas Lindquist Olsen <tomas.l.olsen gmail com> |
---|---|
date | Thu, 14 May 2009 13:26:40 +0200 |
parents | 854e86eaa022 |
children | 34f2fd925de3 |
line wrap: on
line diff
--- a/gen/functions.cpp Wed May 13 18:08:40 2009 +0200 +++ b/gen/functions.cpp Thu May 14 13:26:40 2009 +0200 @@ -683,6 +683,7 @@ gIR->scopes.push_back(IRScope(beginbb, endbb)); // create alloca point + // this gets erased when the function is complete, so alignment etc does not matter at all llvm::Instruction* allocaPoint = new llvm::AllocaInst(LLType::Int32Ty, "alloca point", beginbb); irfunction->allocapoint = allocaPoint; @@ -704,7 +705,7 @@ LLValue* thisvar = irfunction->thisArg; assert(thisvar); - LLValue* thismem = DtoAlloca(thisvar->getType(), "this"); + LLValue* thismem = DtoRawAlloca(thisvar->getType(), 0, "this"); // FIXME: align? DtoStore(thisvar, thismem); irfunction->thisArg = thismem; @@ -760,7 +761,7 @@ argt = irloc->value->getType(); else argt = DtoType(vd->type); - LLValue* mem = DtoAlloca(argt, vd->ident->toChars()); + LLValue* mem = DtoRawAlloca(argt, 0, vd->ident->toChars()); // let the abi transform the argument back first DImValue arg_dval(vd->type, irloc->value); @@ -796,19 +797,19 @@ DtoNestedInit(fd->vresult); } else if (fd->vresult) { fd->vresult->ir.irLocal = new IrLocal(fd->vresult); - fd->vresult->ir.irLocal->value = DtoAlloca(DtoType(fd->vresult->type), fd->vresult->toChars()); + fd->vresult->ir.irLocal->value = DtoAlloca(fd->vresult->type, fd->vresult->toChars()); } // copy _argptr and _arguments to a memory location if (f->linkage == LINKd && f->varargs == 1) { // _argptr - LLValue* argptrmem = DtoAlloca(fd->ir.irFunc->_argptr->getType(), "_argptr_mem"); + LLValue* argptrmem = DtoRawAlloca(fd->ir.irFunc->_argptr->getType(), 0, "_argptr_mem"); new llvm::StoreInst(fd->ir.irFunc->_argptr, argptrmem, gIR->scopebb()); fd->ir.irFunc->_argptr = argptrmem; // _arguments - LLValue* argumentsmem = DtoAlloca(fd->ir.irFunc->_arguments->getType(), "_arguments_mem"); + LLValue* argumentsmem = DtoRawAlloca(fd->ir.irFunc->_arguments->getType(), 0, "_arguments_mem"); new llvm::StoreInst(fd->ir.irFunc->_arguments, argumentsmem, gIR->scopebb()); fd->ir.irFunc->_arguments = argumentsmem; } @@ -918,7 +919,7 @@ // byval arg, but expr has no storage yet else if (DtoIsPassedByRef(argexp->type) && (arg->isSlice() || arg->isNull())) { - LLValue* alloc = DtoAlloca(DtoType(argexp->type), ".tmp_arg"); + LLValue* alloc = DtoAlloca(argexp->type, ".tmp_arg"); DVarValue* vv = new DVarValue(argexp->type, alloc); DtoAssign(argexp->loc, vv, arg); arg = vv;