mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 03:52:19 +02:00
Fix for valueless array allocations
This commit is contained in:
parent
fe531be4ef
commit
6dd49f5d9b
4 changed files with 21 additions and 12 deletions
|
@ -7651,11 +7651,17 @@ BfIRValue BfModule::AllocFromType(BfType* type, const BfAllocTarget& allocTarget
|
|||
else
|
||||
{
|
||||
BfArrayType* arrayType = CreateArrayType(type, arrayDim);
|
||||
auto firstElementField = &arrayType->mFieldInstances.back();
|
||||
int arrayClassSize = firstElementField->mDataOffset;
|
||||
sizeValue = GetConstValue(arrayClassSize);
|
||||
BfIRValue elementDataSize = mBfIRBuilder->CreateMul(GetConstValue(type->GetStride()), arraySize);
|
||||
sizeValue = mBfIRBuilder->CreateAdd(sizeValue, elementDataSize);
|
||||
auto firstElementField = &arrayType->mFieldInstances.back();
|
||||
|
||||
if (!type->IsValuelessType())
|
||||
{
|
||||
int arrayClassSize = firstElementField->mDataOffset;
|
||||
sizeValue = GetConstValue(arrayClassSize);
|
||||
BfIRValue elementDataSize = mBfIRBuilder->CreateMul(GetConstValue(type->GetStride()), arraySize);
|
||||
sizeValue = mBfIRBuilder->CreateAdd(sizeValue, elementDataSize);
|
||||
}
|
||||
else
|
||||
sizeValue = GetConstValue(arrayType->mInstSize);
|
||||
|
||||
auto prevBlock = mBfIRBuilder->GetInsertBlock();
|
||||
isDynAlloc = (isDynAlloc) || (!sizeValue.IsConst());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue