1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 04:22:20 +02:00

ByVal fixes

This commit is contained in:
Brian Fiete 2021-09-16 07:56:55 -07:00
parent 9158002a42
commit 0dc45cb712
4 changed files with 7 additions and 5 deletions

View file

@ -5846,7 +5846,7 @@ BfTypedValue BfExprEvaluator::CreateCall(BfAstNode* targetSrc, BfMethodInstance*
mModule->mBfIRBuilder->Call_AddAttribute(callInst, argIdx + 1, BfIRAttribute_NoCapture);
addDeref = paramType->mSize;
}
else if ((methodInstance->WantsStructsAttribByVal()) && (!paramType->IsSizedArray()))
else if (methodInstance->WantsStructsAttribByVal(paramType))
{
mModule->mBfIRBuilder->Call_AddAttribute(callInst, argIdx + 1, BfIRAttribute_ByVal, mModule->mSystem->mPtrSize);
}

View file

@ -16320,7 +16320,7 @@ void BfModule::SetupIRMethod(BfMethodInstance* methodInstance, BfIRFunction func
PopulateType(resolvedTypeRef, BfPopulateType_Data);
addDeref = resolvedTypeRef->mSize;
}
else if ((methodInstance->WantsStructsAttribByVal()) && (!resolvedTypeRef->IsSizedArray()))
else if (methodInstance->WantsStructsAttribByVal(resolvedTypeRef))
{
mBfIRBuilder->PopulateType(resolvedTypeRef, BfIRPopulateType_Full);
BF_ASSERT(resolvedTypeRef->mAlign > 0);

View file

@ -820,13 +820,15 @@ bool BfMethodInstance::GetLoweredReturnType(BfTypeCode* loweredTypeCode, BfTypeC
return mReturnType->GetLoweredType((mMethodDef->mIsStatic || forceStatic) ? BfTypeUsage_Return_Static : BfTypeUsage_Return_NonStatic, loweredTypeCode, loweredTypeCode2);
}
bool BfMethodInstance::WantsStructsAttribByVal()
bool BfMethodInstance::WantsStructsAttribByVal(BfType* paramType)
{
auto owner = GetOwner();
if ((owner->mModule->mCompiler->mOptions.mPlatformType == BfPlatformType_Windows) &&
(owner->mModule->mCompiler->mOptions.mMachineType == BfMachineType_x64))
return false;
return true;
auto typeInst = paramType->ToTypeInstance();
return (typeInst != NULL) && (typeInst->mIsCRepr);
}
bool BfMethodInstance::IsSkipCall(bool bypassVirtual)

View file

@ -933,7 +933,7 @@ public:
int GetStructRetIdx(bool forceStatic = false);
bool HasSelf();
bool GetLoweredReturnType(BfTypeCode* loweredTypeCode = NULL, BfTypeCode* loweredTypeCode2 = NULL, bool forceStatic = false);
bool WantsStructsAttribByVal();
bool WantsStructsAttribByVal(BfType* paramType);
bool IsAutocompleteMethod() { /*return mIdHash == -1;*/ return mIsAutocompleteMethod; }
bool IsSkipCall(bool bypassVirtual = false);
bool IsVarArgs();