mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +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
|
@ -1397,6 +1397,11 @@ void BeIRCodeGen::HandleNextCmd()
|
||||||
CMD_PARAM(BeType*, type);
|
CMD_PARAM(BeType*, type);
|
||||||
CMD_PARAM(BeValue*, arraySize);
|
CMD_PARAM(BeValue*, arraySize);
|
||||||
|
|
||||||
|
if (auto constant = BeValueDynCast<BeConstant>(arraySize))
|
||||||
|
{
|
||||||
|
//BF_ASSERT(constant->mInt64 >= 0);
|
||||||
|
}
|
||||||
|
|
||||||
auto allocaInst = mBeModule->AllocInst<BeAllocaInst>();
|
auto allocaInst = mBeModule->AllocInst<BeAllocaInst>();
|
||||||
allocaInst->mType = type;
|
allocaInst->mType = type;
|
||||||
allocaInst->mAlign = type->mAlign;
|
allocaInst->mAlign = type->mAlign;
|
||||||
|
|
|
@ -11279,8 +11279,11 @@ void BfExprEvaluator::Visit(BfObjectCreateExpression* objCreateExpr)
|
||||||
}
|
}
|
||||||
|
|
||||||
mModule->mBfIRBuilder->PopulateType(resultType);
|
mModule->mBfIRBuilder->PopulateType(resultType);
|
||||||
mModule->mBfIRBuilder->CreateMemSet(mModule->CreateIndexedValue(resultType, addr, clearFromIdx),
|
if (!resultType->IsValuelessType())
|
||||||
mModule->mBfIRBuilder->CreateConst(BfTypeCode_Int8, isUninit ? 0xCC : 0), clearBytes, resultType->mAlign);
|
{
|
||||||
|
mModule->mBfIRBuilder->CreateMemSet(mModule->CreateIndexedValue(resultType, addr, clearFromIdx),
|
||||||
|
mModule->mBfIRBuilder->CreateConst(BfTypeCode_Int8, isUninit ? 0xCC : 0), clearBytes, resultType->mAlign);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -7652,10 +7652,16 @@ BfIRValue BfModule::AllocFromType(BfType* type, const BfAllocTarget& allocTarget
|
||||||
{
|
{
|
||||||
BfArrayType* arrayType = CreateArrayType(type, arrayDim);
|
BfArrayType* arrayType = CreateArrayType(type, arrayDim);
|
||||||
auto firstElementField = &arrayType->mFieldInstances.back();
|
auto firstElementField = &arrayType->mFieldInstances.back();
|
||||||
int arrayClassSize = firstElementField->mDataOffset;
|
|
||||||
sizeValue = GetConstValue(arrayClassSize);
|
if (!type->IsValuelessType())
|
||||||
BfIRValue elementDataSize = mBfIRBuilder->CreateMul(GetConstValue(type->GetStride()), arraySize);
|
{
|
||||||
sizeValue = mBfIRBuilder->CreateAdd(sizeValue, elementDataSize);
|
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();
|
auto prevBlock = mBfIRBuilder->GetInsertBlock();
|
||||||
isDynAlloc = (isDynAlloc) || (!sizeValue.IsConst());
|
isDynAlloc = (isDynAlloc) || (!sizeValue.IsConst());
|
||||||
|
|
|
@ -3324,11 +3324,6 @@ void BfModule::DoTypeInstanceMethodProcessing(BfTypeInstance* typeInstance)
|
||||||
BF_ASSERT(typeInstance->mInterfaceMethodTable.size() == 1);
|
BF_ASSERT(typeInstance->mInterfaceMethodTable.size() == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeInstance->mTypeDef == mCompiler->mPointerTypeDef)
|
|
||||||
{
|
|
||||||
NOP;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Slot interfaces method blocks in vtable
|
// Slot interfaces method blocks in vtable
|
||||||
{
|
{
|
||||||
int ifaceVirtIdx = 0;
|
int ifaceVirtIdx = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue