mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-08-05 22:10:04 +02:00
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 .
This commit is contained in:
@@ -33,7 +33,7 @@ static LLValue* to_pkey(Loc& loc, DValue* key)
|
|||||||
pkey = key->getRVal();
|
pkey = key->getRVal();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LLValue* tmp = DtoAlloca(DtoType(keytype), "aatmpkeystorage");
|
LLValue* tmp = DtoAlloca(keytype, "aatmpkeystorage");
|
||||||
DVarValue var(keytype, tmp);
|
DVarValue var(keytype, tmp);
|
||||||
DtoAssign(loc, &var, key);
|
DtoAssign(loc, &var, key);
|
||||||
return tmp;
|
return tmp;
|
||||||
@@ -41,7 +41,7 @@ static LLValue* to_pkey(Loc& loc, DValue* key)
|
|||||||
|
|
||||||
// give memory
|
// give memory
|
||||||
if (needmem) {
|
if (needmem) {
|
||||||
LLValue* tmp = DtoAlloca(DtoType(keytype), "aatmpkeystorage");
|
LLValue* tmp = DtoAlloca(keytype, "aatmpkeystorage");
|
||||||
DtoStore(pkey, tmp);
|
DtoStore(pkey, tmp);
|
||||||
pkey = tmp;
|
pkey = tmp;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -455,7 +455,7 @@ struct X86_64_C_struct_rewrite : ABIRewrite {
|
|||||||
} else {
|
} else {
|
||||||
// No memory location, create one.
|
// No memory location, create one.
|
||||||
LLValue* rval = v->getRVal();
|
LLValue* rval = v->getRVal();
|
||||||
lval = DtoAlloca(rval->getType());
|
lval = DtoRawAlloca(rval->getType(), 0);
|
||||||
DtoStore(rval, lval);
|
DtoStore(rval, lval);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -479,7 +479,7 @@ struct X86_64_C_struct_rewrite : ABIRewrite {
|
|||||||
} else {
|
} else {
|
||||||
// No memory location, create one.
|
// No memory location, create one.
|
||||||
LLValue* rval = v->getRVal();
|
LLValue* rval = v->getRVal();
|
||||||
lval = DtoAlloca(rval->getType());
|
lval = DtoRawAlloca(rval->getType(), 0);
|
||||||
DtoStore(rval, lval);
|
DtoStore(rval, lval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ struct X86_struct_to_register : ABIRewrite
|
|||||||
LLValue* get(Type* dty, DValue* dv)
|
LLValue* get(Type* dty, DValue* dv)
|
||||||
{
|
{
|
||||||
Logger::println("rewriting int -> struct");
|
Logger::println("rewriting int -> struct");
|
||||||
LLValue* mem = DtoAlloca(DtoType(dty), ".int_to_struct");
|
LLValue* mem = DtoAlloca(dty, ".int_to_struct");
|
||||||
LLValue* v = dv->getRVal();
|
LLValue* v = dv->getRVal();
|
||||||
DtoStore(v, DtoBitCast(mem, getPtrToType(v->getType())));
|
DtoStore(v, DtoBitCast(mem, getPtrToType(v->getType())));
|
||||||
return DtoLoad(mem);
|
return DtoLoad(mem);
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ void DtoArrayInit(Loc& loc, DValue* array, DValue* value)
|
|||||||
// give slices and complex values storage (and thus an address to pass)
|
// give slices and complex values storage (and thus an address to pass)
|
||||||
if (value->isSlice())
|
if (value->isSlice())
|
||||||
{
|
{
|
||||||
val = DtoAlloca(DtoType(value->getType()), ".tmpparam");
|
val = DtoAlloca(value->getType(), ".tmpparam");
|
||||||
DVarValue lval(value->getType(), val);
|
DVarValue lval(value->getType(), val);
|
||||||
DtoAssign(loc, &lval, value);
|
DtoAssign(loc, &lval, value);
|
||||||
}
|
}
|
||||||
@@ -448,7 +448,7 @@ DSliceValue* DtoNewMulDimDynArray(Loc& loc, Type* arrayType, DValue** dims, size
|
|||||||
LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, fnname);
|
LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, fnname);
|
||||||
|
|
||||||
// build dims
|
// build dims
|
||||||
LLValue* dimsArg = DtoAlloca(DtoSize_t(), DtoConstUint(ndims), ".newdims");
|
LLValue* dimsArg = DtoArrayAlloca(Type::tsize_t, ndims, ".newdims");
|
||||||
LLValue* firstDim = NULL;
|
LLValue* firstDim = NULL;
|
||||||
for (size_t i=0; i<ndims; ++i)
|
for (size_t i=0; i<ndims; ++i)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -600,7 +600,7 @@ void AsmBlockStatement::toIR(IRState* p)
|
|||||||
outSetterStmt->code += asmGotoEndLabel.str()+":\n";
|
outSetterStmt->code += asmGotoEndLabel.str()+":\n";
|
||||||
|
|
||||||
// create storage for and initialize the temporary
|
// create storage for and initialize the temporary
|
||||||
jump_target = DtoAlloca(LLType::Int32Ty, "__llvm_jump_target");
|
jump_target = DtoAlloca(Type::tint32, "__llvm_jump_target");
|
||||||
gIR->ir->CreateStore(DtoConstUint(0), jump_target);
|
gIR->ir->CreateStore(DtoConstUint(0), jump_target);
|
||||||
// setup variable for output from asm
|
// setup variable for output from asm
|
||||||
outSetterStmt->out_c = "=*m,";
|
outSetterStmt->out_c = "=*m,";
|
||||||
|
|||||||
@@ -129,7 +129,8 @@ DValue* DtoNewClass(Loc loc, TypeClass* tc, NewExp* newexp)
|
|||||||
LLValue* mem;
|
LLValue* mem;
|
||||||
if (newexp->onstack)
|
if (newexp->onstack)
|
||||||
{
|
{
|
||||||
mem = DtoAlloca(DtoType(tc)->getContainedType(0), ".newclass_alloca");
|
// FIXME align scope class to its largest member
|
||||||
|
mem = DtoRawAlloca(DtoType(tc)->getContainedType(0), 0, ".newclass_alloca");
|
||||||
}
|
}
|
||||||
// custom allocator
|
// custom allocator
|
||||||
else if (newexp->allocator)
|
else if (newexp->allocator)
|
||||||
|
|||||||
@@ -683,6 +683,7 @@ void DtoDefineFunction(FuncDeclaration* fd)
|
|||||||
gIR->scopes.push_back(IRScope(beginbb, endbb));
|
gIR->scopes.push_back(IRScope(beginbb, endbb));
|
||||||
|
|
||||||
// create alloca point
|
// 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);
|
llvm::Instruction* allocaPoint = new llvm::AllocaInst(LLType::Int32Ty, "alloca point", beginbb);
|
||||||
irfunction->allocapoint = allocaPoint;
|
irfunction->allocapoint = allocaPoint;
|
||||||
|
|
||||||
@@ -704,7 +705,7 @@ void DtoDefineFunction(FuncDeclaration* fd)
|
|||||||
LLValue* thisvar = irfunction->thisArg;
|
LLValue* thisvar = irfunction->thisArg;
|
||||||
assert(thisvar);
|
assert(thisvar);
|
||||||
|
|
||||||
LLValue* thismem = DtoAlloca(thisvar->getType(), "this");
|
LLValue* thismem = DtoRawAlloca(thisvar->getType(), 0, "this"); // FIXME: align?
|
||||||
DtoStore(thisvar, thismem);
|
DtoStore(thisvar, thismem);
|
||||||
irfunction->thisArg = thismem;
|
irfunction->thisArg = thismem;
|
||||||
|
|
||||||
@@ -760,7 +761,7 @@ void DtoDefineFunction(FuncDeclaration* fd)
|
|||||||
argt = irloc->value->getType();
|
argt = irloc->value->getType();
|
||||||
else
|
else
|
||||||
argt = DtoType(vd->type);
|
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
|
// let the abi transform the argument back first
|
||||||
DImValue arg_dval(vd->type, irloc->value);
|
DImValue arg_dval(vd->type, irloc->value);
|
||||||
@@ -796,19 +797,19 @@ void DtoDefineFunction(FuncDeclaration* fd)
|
|||||||
DtoNestedInit(fd->vresult);
|
DtoNestedInit(fd->vresult);
|
||||||
} else if (fd->vresult) {
|
} else if (fd->vresult) {
|
||||||
fd->vresult->ir.irLocal = new IrLocal(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
|
// copy _argptr and _arguments to a memory location
|
||||||
if (f->linkage == LINKd && f->varargs == 1)
|
if (f->linkage == LINKd && f->varargs == 1)
|
||||||
{
|
{
|
||||||
// _argptr
|
// _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());
|
new llvm::StoreInst(fd->ir.irFunc->_argptr, argptrmem, gIR->scopebb());
|
||||||
fd->ir.irFunc->_argptr = argptrmem;
|
fd->ir.irFunc->_argptr = argptrmem;
|
||||||
|
|
||||||
// _arguments
|
// _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());
|
new llvm::StoreInst(fd->ir.irFunc->_arguments, argumentsmem, gIR->scopebb());
|
||||||
fd->ir.irFunc->_arguments = argumentsmem;
|
fd->ir.irFunc->_arguments = argumentsmem;
|
||||||
}
|
}
|
||||||
@@ -918,7 +919,7 @@ DValue* DtoArgument(Argument* fnarg, Expression* argexp)
|
|||||||
// byval arg, but expr has no storage yet
|
// byval arg, but expr has no storage yet
|
||||||
else if (DtoIsPassedByRef(argexp->type) && (arg->isSlice() || arg->isNull()))
|
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);
|
DVarValue* vv = new DVarValue(argexp->type, alloc);
|
||||||
DtoAssign(argexp->loc, vv, arg);
|
DtoAssign(argexp->loc, vv, arg);
|
||||||
arg = vv;
|
arg = vv;
|
||||||
|
|||||||
@@ -95,14 +95,29 @@ void DtoDeleteArray(DValue* arr)
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////*/
|
////////////////////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
|
||||||
llvm::AllocaInst* DtoAlloca(const LLType* lltype, const std::string& name)
|
llvm::AllocaInst* DtoAlloca(Type* type, const char* name)
|
||||||
{
|
{
|
||||||
return new llvm::AllocaInst(lltype, name, gIR->topallocapoint());
|
const llvm::Type* lltype = DtoType(type);
|
||||||
|
llvm::AllocaInst* ai = new llvm::AllocaInst(lltype, name, gIR->topallocapoint());
|
||||||
|
ai->setAlignment(type->alignsize());
|
||||||
|
return ai;
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::AllocaInst* DtoAlloca(const LLType* lltype, LLValue* arraysize, const std::string& name)
|
llvm::AllocaInst* DtoArrayAlloca(Type* type, unsigned arraysize, const char* name)
|
||||||
{
|
{
|
||||||
return new llvm::AllocaInst(lltype, arraysize, name, gIR->topallocapoint());
|
const llvm::Type* lltype = DtoType(type);
|
||||||
|
llvm::AllocaInst* ai = new llvm::AllocaInst(
|
||||||
|
lltype, DtoConstUint(arraysize), name, gIR->topallocapoint());
|
||||||
|
ai->setAlignment(type->alignsize());
|
||||||
|
return ai;
|
||||||
|
}
|
||||||
|
|
||||||
|
llvm::AllocaInst* DtoRawAlloca(const llvm::Type* lltype, size_t alignment, const char* name)
|
||||||
|
{
|
||||||
|
llvm::AllocaInst* ai = new llvm::AllocaInst(lltype, name, gIR->topallocapoint());
|
||||||
|
if (alignment)
|
||||||
|
ai->setAlignment(alignment);
|
||||||
|
return ai;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -894,7 +909,7 @@ DValue* DtoDeclarationExp(Dsymbol* declaration)
|
|||||||
if(gTargetData->getTypeSizeInBits(lltype) == 0)
|
if(gTargetData->getTypeSizeInBits(lltype) == 0)
|
||||||
allocainst = llvm::ConstantPointerNull::get(getPtrToType(lltype));
|
allocainst = llvm::ConstantPointerNull::get(getPtrToType(lltype));
|
||||||
else
|
else
|
||||||
allocainst = DtoAlloca(lltype, vd->toChars());
|
allocainst = DtoAlloca(vd->type, vd->toChars());
|
||||||
|
|
||||||
//allocainst->setAlignment(vd->type->alignsize()); // TODO
|
//allocainst->setAlignment(vd->type->alignsize()); // TODO
|
||||||
vd->ir.irLocal = new IrLocal(vd);
|
vd->ir.irLocal = new IrLocal(vd);
|
||||||
@@ -1010,7 +1025,7 @@ LLValue* DtoRawVarDeclaration(VarDeclaration* var, LLValue* addr)
|
|||||||
LLValue* allocaval = NULL;
|
LLValue* allocaval = NULL;
|
||||||
if (!addr && (!var->ir.irLocal || !var->ir.irLocal->value))
|
if (!addr && (!var->ir.irLocal || !var->ir.irLocal->value))
|
||||||
{
|
{
|
||||||
addr = DtoAlloca(DtoType(var->type), var->toChars());
|
addr = DtoAlloca(var->type, var->toChars());
|
||||||
|
|
||||||
// add debug info
|
// add debug info
|
||||||
if (global.params.symdebug)
|
if (global.params.symdebug)
|
||||||
|
|||||||
@@ -40,8 +40,9 @@ void DtoDeleteInterface(LLValue* inst);
|
|||||||
void DtoDeleteArray(DValue* arr);
|
void DtoDeleteArray(DValue* arr);
|
||||||
|
|
||||||
// emit an alloca
|
// emit an alloca
|
||||||
llvm::AllocaInst* DtoAlloca(const LLType* lltype, const std::string& name = "");
|
llvm::AllocaInst* DtoAlloca(Type* type, const char* name = "");
|
||||||
llvm::AllocaInst* DtoAlloca(const LLType* lltype, LLValue* arraysize, const std::string& name = "");
|
llvm::AllocaInst* DtoArrayAlloca(Type* type, unsigned arraysize, const char* name = "");
|
||||||
|
llvm::AllocaInst* DtoRawAlloca(const llvm::Type* lltype, size_t alignment, const char* name = "");
|
||||||
|
|
||||||
// assertion generator
|
// assertion generator
|
||||||
void DtoAssert(Module* M, Loc loc, DValue* msg);
|
void DtoAssert(Module* M, Loc loc, DValue* msg);
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ void emitABIReturnAsmStmt(IRAsmBlock* asmblock, Loc loc, FuncDeclaration* fdecl)
|
|||||||
|
|
||||||
// generate asm
|
// generate asm
|
||||||
as->out_c = "=*m,=*m,";
|
as->out_c = "=*m,=*m,";
|
||||||
LLValue* tmp = DtoAlloca(llretTy, ".tmp_asm_ret");
|
LLValue* tmp = DtoRawAlloca(llretTy, 0, ".tmp_asm_ret");
|
||||||
as->out.push_back( tmp );
|
as->out.push_back( tmp );
|
||||||
as->out.push_back( DtoGEPi(tmp, 0,1) );
|
as->out.push_back( DtoGEPi(tmp, 0,1) );
|
||||||
as->code = "movd %eax, $<<out0>>" "\n\t" "mov %edx, $<<out1>>";
|
as->code = "movd %eax, $<<out0>>" "\n\t" "mov %edx, $<<out1>>";
|
||||||
@@ -413,7 +413,7 @@ DValue * DtoInlineAsmExpr(Loc loc, FuncDeclaration * fd, Expressions * arguments
|
|||||||
if (type->ty == Tstruct)
|
if (type->ty == Tstruct)
|
||||||
{
|
{
|
||||||
// make a copy
|
// make a copy
|
||||||
llvm::Value* mem = DtoAlloca(ret_type, ".__asm_tuple_ret");
|
llvm::Value* mem = DtoAlloca(type, ".__asm_tuple_ret");
|
||||||
|
|
||||||
TypeStruct* ts = (TypeStruct*)type;
|
TypeStruct* ts = (TypeStruct*)type;
|
||||||
size_t n = ts->sym->fields.dim;
|
size_t n = ts->sym->fields.dim;
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ void DtoNestedInit(VarDeclaration* vd)
|
|||||||
if (nestedCtx == NCArray) {
|
if (nestedCtx == NCArray) {
|
||||||
// alloca as usual if no value already
|
// alloca as usual if no value already
|
||||||
if (!vd->ir.irLocal->value)
|
if (!vd->ir.irLocal->value)
|
||||||
vd->ir.irLocal->value = DtoAlloca(DtoType(vd->type), vd->toChars());
|
vd->ir.irLocal->value = DtoAlloca(vd->type, vd->toChars());
|
||||||
|
|
||||||
// store the address into the nested vars array
|
// store the address into the nested vars array
|
||||||
assert(vd->ir.irLocal->nestedIndex >= 0);
|
assert(vd->ir.irLocal->nestedIndex >= 0);
|
||||||
@@ -324,7 +324,8 @@ void DtoCreateNestedContext(FuncDeclaration* fd) {
|
|||||||
const LLType* nestedVarsTy = LLArrayType::get(getVoidPtrType(), nelems);
|
const LLType* nestedVarsTy = LLArrayType::get(getVoidPtrType(), nelems);
|
||||||
|
|
||||||
// alloca it
|
// alloca it
|
||||||
LLValue* nestedVars = DtoAlloca(nestedVarsTy, ".nested_vars");
|
// FIXME align ?
|
||||||
|
LLValue* nestedVars = DtoRawAlloca(nestedVarsTy, 0, ".nested_vars");
|
||||||
|
|
||||||
IrFunction* irfunction = fd->ir.irFunc;
|
IrFunction* irfunction = fd->ir.irFunc;
|
||||||
|
|
||||||
@@ -459,7 +460,8 @@ void DtoCreateNestedContext(FuncDeclaration* fd) {
|
|||||||
// FIXME: For D2, this should be a gc_malloc (or similar) call, not alloca
|
// FIXME: For D2, this should be a gc_malloc (or similar) call, not alloca
|
||||||
// (Note that it'd also require more aggressive copying of
|
// (Note that it'd also require more aggressive copying of
|
||||||
// by-value parameters instead of just alloca'd ones)
|
// by-value parameters instead of just alloca'd ones)
|
||||||
LLValue* frame = DtoAlloca(frameType, ".frame");
|
// FIXME: alignment ?
|
||||||
|
LLValue* frame = DtoRawAlloca(frameType, 0, ".frame");
|
||||||
|
|
||||||
// copy parent frames into beginning
|
// copy parent frames into beginning
|
||||||
if (depth != 0) {
|
if (depth != 0) {
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ namespace {
|
|||||||
NumGcToStack++;
|
NumGcToStack++;
|
||||||
|
|
||||||
Instruction* Begin = CS.getCaller()->getEntryBlock().begin();
|
Instruction* Begin = CS.getCaller()->getEntryBlock().begin();
|
||||||
return new AllocaInst(Ty, ".nongc_mem", Begin);
|
return new AllocaInst(Ty, ".nongc_mem", Begin); // FIXME: align?
|
||||||
}
|
}
|
||||||
|
|
||||||
FunctionInfo(unsigned typeInfoArgNr, bool safeToDelete)
|
FunctionInfo(unsigned typeInfoArgNr, bool safeToDelete)
|
||||||
@@ -165,7 +165,7 @@ namespace {
|
|||||||
|
|
||||||
// Convert array size to 32 bits if necessary
|
// Convert array size to 32 bits if necessary
|
||||||
Value* count = Builder.CreateIntCast(arrSize, Type::Int32Ty, false);
|
Value* count = Builder.CreateIntCast(arrSize, Type::Int32Ty, false);
|
||||||
AllocaInst* alloca = Builder.CreateAlloca(Ty, count, ".nongc_mem");
|
AllocaInst* alloca = Builder.CreateAlloca(Ty, count, ".nongc_mem"); // FIXME: align?
|
||||||
|
|
||||||
if (Initialized) {
|
if (Initialized) {
|
||||||
// For now, only zero-init is supported.
|
// For now, only zero-init is supported.
|
||||||
|
|||||||
@@ -1025,7 +1025,7 @@ void ForeachStatement::toIR(IRState* p)
|
|||||||
if (key)
|
if (key)
|
||||||
keyvar = DtoRawVarDeclaration(key);
|
keyvar = DtoRawVarDeclaration(key);
|
||||||
else
|
else
|
||||||
keyvar = DtoAlloca(keytype, "foreachkey");
|
keyvar = DtoRawAlloca(keytype, 0, "foreachkey"); // FIXME: align?
|
||||||
LLValue* zerokey = llvm::ConstantInt::get(keytype,0,false);
|
LLValue* zerokey = llvm::ConstantInt::get(keytype,0,false);
|
||||||
|
|
||||||
// value
|
// value
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ void DtoBuildDVarArgList(std::vector<LLValue*>& args, std::vector<llvm::Attribut
|
|||||||
if (Logger::enabled())
|
if (Logger::enabled())
|
||||||
Logger::cout() << "d-variadic argument struct type:\n" << *vtype << '\n';
|
Logger::cout() << "d-variadic argument struct type:\n" << *vtype << '\n';
|
||||||
|
|
||||||
LLValue* mem = DtoAlloca(vtype,"_argptr_storage");
|
LLValue* mem = DtoRawAlloca(vtype, 0, "_argptr_storage");
|
||||||
|
|
||||||
// store arguments in the struct
|
// store arguments in the struct
|
||||||
for (int i=begin,k=0; i<n_arguments; i++,k++)
|
for (int i=begin,k=0; i<n_arguments; i++,k++)
|
||||||
@@ -316,7 +316,7 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions*
|
|||||||
// return in hidden ptr is first
|
// return in hidden ptr is first
|
||||||
if (retinptr)
|
if (retinptr)
|
||||||
{
|
{
|
||||||
LLValue* retvar = DtoAlloca(argiter->get()->getContainedType(0), ".rettmp");
|
LLValue* retvar = DtoRawAlloca(argiter->get()->getContainedType(0), 0, ".rettmp");
|
||||||
++argiter;
|
++argiter;
|
||||||
args.push_back(retvar);
|
args.push_back(retvar);
|
||||||
|
|
||||||
@@ -552,7 +552,7 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions*
|
|||||||
// pointer to a struct, store it to a stack slot before continuing.
|
// pointer to a struct, store it to a stack slot before continuing.
|
||||||
if (tf->next->ty == Tstruct && !isaPointer(retllval)) {
|
if (tf->next->ty == Tstruct && !isaPointer(retllval)) {
|
||||||
Logger::println("Storing return value to stack slot");
|
Logger::println("Storing return value to stack slot");
|
||||||
LLValue* mem = DtoAlloca(retllval->getType());
|
LLValue* mem = DtoRawAlloca(retllval->getType(), 0);
|
||||||
DtoStore(retllval, mem);
|
DtoStore(retllval, mem);
|
||||||
retllval = mem;
|
retllval = mem;
|
||||||
}
|
}
|
||||||
|
|||||||
14
gen/toir.cpp
14
gen/toir.cpp
@@ -909,7 +909,7 @@ DValue* AddrExp::toElem(IRState* p)
|
|||||||
{
|
{
|
||||||
assert(v->isSlice());
|
assert(v->isSlice());
|
||||||
LLValue* rval = v->getRVal();
|
LLValue* rval = v->getRVal();
|
||||||
lval = DtoAlloca(rval->getType(), ".tmp_slice_storage");
|
lval = DtoRawAlloca(rval->getType(), 0, ".tmp_slice_storage");
|
||||||
DtoStore(rval, lval);
|
DtoStore(rval, lval);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2124,13 +2124,12 @@ DValue* CondExp::toElem(IRState* p)
|
|||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
|
|
||||||
Type* dtype = type->toBasetype();
|
Type* dtype = type->toBasetype();
|
||||||
const LLType* resty = DtoType(dtype);
|
|
||||||
|
|
||||||
DValue* dvv;
|
DValue* dvv;
|
||||||
// voids returns will need no storage
|
// voids returns will need no storage
|
||||||
if (dtype->ty != Tvoid) {
|
if (dtype->ty != Tvoid) {
|
||||||
// allocate a temporary for the final result. failed to come up with a better way :/
|
// allocate a temporary for the final result. failed to come up with a better way :/
|
||||||
LLValue* resval = DtoAlloca(resty,"condtmp");
|
LLValue* resval = DtoAlloca(dtype,"condtmp");
|
||||||
dvv = new DVarValue(type, resval);
|
dvv = new DVarValue(type, resval);
|
||||||
} else {
|
} else {
|
||||||
dvv = new DConstValue(type, getNullValue(DtoTypeNotVoid(dtype)));
|
dvv = new DConstValue(type, getNullValue(DtoTypeNotVoid(dtype)));
|
||||||
@@ -2345,7 +2344,7 @@ DValue* ArrayLiteralExp::toElem(IRState* p)
|
|||||||
dstMem = dynSlice->ptr;
|
dstMem = dynSlice->ptr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
dstMem = DtoAlloca(llStoType, "arrayliteral");
|
dstMem = DtoRawAlloca(llStoType, 0, "arrayliteral");
|
||||||
|
|
||||||
// store elements
|
// store elements
|
||||||
for (size_t i=0; i<len; ++i)
|
for (size_t i=0; i<len; ++i)
|
||||||
@@ -2509,7 +2508,7 @@ DValue* StructLiteralExp::toElem(IRState* p)
|
|||||||
const LLType* st = llvm::StructType::get(valuetypes, packed);
|
const LLType* st = llvm::StructType::get(valuetypes, packed);
|
||||||
|
|
||||||
// alloca a stack slot
|
// alloca a stack slot
|
||||||
LLValue* mem = DtoAlloca(st, ".structliteral");
|
LLValue* mem = DtoRawAlloca(st, 0, ".structliteral");
|
||||||
|
|
||||||
// fill in values
|
// fill in values
|
||||||
for (size_t i = 0; i < n; i++)
|
for (size_t i = 0; i < n; i++)
|
||||||
@@ -2596,12 +2595,11 @@ DValue* AssocArrayLiteralExp::toElem(IRState* p)
|
|||||||
|
|
||||||
Type* aatype = type->toBasetype();
|
Type* aatype = type->toBasetype();
|
||||||
Type* vtype = aatype->nextOf();
|
Type* vtype = aatype->nextOf();
|
||||||
const LLType* aalltype = DtoType(type);
|
|
||||||
|
|
||||||
// it should be possible to avoid the temporary in some cases
|
// it should be possible to avoid the temporary in some cases
|
||||||
LLValue* tmp = DtoAlloca(aalltype,"aaliteral");
|
LLValue* tmp = DtoAlloca(type,"aaliteral");
|
||||||
DValue* aa = new DVarValue(type, tmp);
|
DValue* aa = new DVarValue(type, tmp);
|
||||||
DtoStore(LLConstant::getNullValue(aalltype), tmp);
|
DtoStore(LLConstant::getNullValue(DtoType(type)), tmp);
|
||||||
|
|
||||||
const size_t n = keys->dim;
|
const size_t n = keys->dim;
|
||||||
for (size_t i=0; i<n; ++i)
|
for (size_t i=0; i<n; ++i)
|
||||||
|
|||||||
@@ -206,8 +206,7 @@ LLValue* IRLandingPad::getExceptionStorage()
|
|||||||
if(!catch_var)
|
if(!catch_var)
|
||||||
{
|
{
|
||||||
Logger::println("Making new catch var");
|
Logger::println("Making new catch var");
|
||||||
const LLType* objectTy = DtoType(ClassDeclaration::object->type);
|
catch_var = DtoAlloca(ClassDeclaration::object->type, "catchvar");
|
||||||
catch_var = DtoAlloca(objectTy,"catchvar");
|
|
||||||
}
|
}
|
||||||
return catch_var;
|
return catch_var;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user