mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-04-29 22:50:53 +03:00
Merge branch 'master' into merge-2.068
This commit is contained in:
commit
b63a5e3cf8
18 changed files with 88 additions and 49 deletions
|
@ -134,6 +134,24 @@ void DtoDeleteArray(Loc& loc, DValue* arr)
|
|||
);
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
/*////////////////////////////////////////////////////////////////////////////////////////
|
||||
// ALIGNMENT HELPERS
|
||||
////////////////////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
unsigned DtoAlignment(Type* type)
|
||||
{
|
||||
structalign_t alignment = type->alignment();
|
||||
if (alignment == STRUCTALIGN_DEFAULT)
|
||||
alignment = type->alignsize();
|
||||
return (alignment == STRUCTALIGN_DEFAULT ? 0 : alignment);
|
||||
}
|
||||
|
||||
unsigned DtoAlignment(VarDeclaration* vd)
|
||||
{
|
||||
return vd->alignment == STRUCTALIGN_DEFAULT ? DtoAlignment(vd->type) : vd->alignment;
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
/*////////////////////////////////////////////////////////////////////////////////////////
|
||||
// ALLOCA HELPERS
|
||||
|
@ -141,7 +159,12 @@ void DtoDeleteArray(Loc& loc, DValue* arr)
|
|||
|
||||
llvm::AllocaInst* DtoAlloca(Type* type, const char* name)
|
||||
{
|
||||
return DtoRawAlloca(DtoMemType(type), type->alignsize(), name);
|
||||
return DtoRawAlloca(DtoMemType(type), DtoAlignment(type), name);
|
||||
}
|
||||
|
||||
llvm::AllocaInst* DtoAlloca(VarDeclaration* vd, const char* name)
|
||||
{
|
||||
return DtoRawAlloca(DtoMemType(vd->type), DtoAlignment(vd), name);
|
||||
}
|
||||
|
||||
llvm::AllocaInst* DtoArrayAlloca(Type* type, unsigned arraysize, const char* name)
|
||||
|
@ -149,7 +172,7 @@ llvm::AllocaInst* DtoArrayAlloca(Type* type, unsigned arraysize, const char* nam
|
|||
LLType* lltype = DtoType(type);
|
||||
llvm::AllocaInst* ai = new llvm::AllocaInst(
|
||||
lltype, DtoConstUint(arraysize), name, gIR->topallocapoint());
|
||||
ai->setAlignment(type->alignsize());
|
||||
ai->setAlignment(DtoAlignment(type));
|
||||
return ai;
|
||||
}
|
||||
|
||||
|
@ -195,7 +218,7 @@ LLValue* DtoAllocaDump(LLValue* val, int alignment, const char* name)
|
|||
|
||||
LLValue* DtoAllocaDump(LLValue* val, Type* asType, const char* name)
|
||||
{
|
||||
return DtoAllocaDump(val, DtoType(asType), asType->alignsize(), name);
|
||||
return DtoAllocaDump(val, DtoType(asType), DtoAlignment(asType), name);
|
||||
}
|
||||
|
||||
LLValue* DtoAllocaDump(LLValue* val, LLType* asType, int alignment, const char* name)
|
||||
|
@ -869,11 +892,9 @@ void DtoResolveVariable(VarDeclaration* vd)
|
|||
vd->isThreadlocal());
|
||||
getIrGlobal(vd)->value = gvar;
|
||||
|
||||
// Set the alignment (it is important not to use type->alignsize because
|
||||
// VarDeclarations can have an align() attribute independent of the type
|
||||
// as well).
|
||||
if (vd->alignment != STRUCTALIGN_DEFAULT)
|
||||
gvar->setAlignment(vd->alignment);
|
||||
// Set the alignment and use the target pointer size as lower bound.
|
||||
unsigned alignment = std::max(DtoAlignment(vd), gDataLayout->getPointerSize());
|
||||
gvar->setAlignment(alignment);
|
||||
|
||||
IF_LOG Logger::cout() << *gvar << '\n';
|
||||
}
|
||||
|
@ -928,8 +949,10 @@ void DtoVarDeclaration(VarDeclaration* vd)
|
|||
LLType* lltype = DtoType(type);
|
||||
if(gDataLayout->getTypeSizeInBits(lltype) == 0)
|
||||
allocainst = llvm::ConstantPointerNull::get(getPtrToType(lltype));
|
||||
else
|
||||
else if (type != vd->type)
|
||||
allocainst = DtoAlloca(type, vd->toChars());
|
||||
else
|
||||
allocainst = DtoAlloca(vd, vd->toChars());
|
||||
|
||||
irLocal->value = allocainst;
|
||||
|
||||
|
@ -1106,7 +1129,7 @@ LLValue* DtoRawVarDeclaration(VarDeclaration* var, LLValue* addr)
|
|||
// alloca if necessary
|
||||
if (!addr && (!irLocal || !irLocal->value))
|
||||
{
|
||||
addr = DtoAlloca(var->type, var->toChars());
|
||||
addr = DtoAlloca(var, var->toChars());
|
||||
// add debug info
|
||||
if (!irLocal)
|
||||
irLocal = getIrLocal(var, true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue