mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 20:12:21 +02:00
Fixed deferring of sret methods
This commit is contained in:
parent
46cc3d088b
commit
246e56c144
2 changed files with 22 additions and 9 deletions
|
@ -12010,11 +12010,17 @@ BfTypedValue BfModule::MakeAddressable(BfTypedValue typedVal, bool forceMutable)
|
|||
return typedVal;
|
||||
BfType* type = typedVal.mType;
|
||||
PopulateType(type);
|
||||
auto tempVar = CreateAlloca(type);
|
||||
if (typedVal.IsSplat())
|
||||
AggregateSplatIntoAddr(typedVal, tempVar);
|
||||
BfIRValue tempVar;
|
||||
if (typedVal.mValue.IsFake())
|
||||
tempVar = mBfIRBuilder->GetFakeVal();
|
||||
else
|
||||
mBfIRBuilder->CreateAlignedStore(typedVal.mValue, tempVar, type->mAlign);
|
||||
{
|
||||
tempVar = CreateAlloca(type);
|
||||
if (typedVal.IsSplat())
|
||||
AggregateSplatIntoAddr(typedVal, tempVar);
|
||||
else
|
||||
mBfIRBuilder->CreateAlignedStore(typedVal.mValue, tempVar, type->mAlign);
|
||||
}
|
||||
|
||||
if (forceMutable)
|
||||
wasReadOnly = false;
|
||||
|
|
|
@ -72,12 +72,19 @@ bool BfModule::AddDeferredCallEntry(BfDeferredCallEntry* deferredCallEntry, BfSc
|
|||
SizedArray<BfIRType, 8> origParamTypes;
|
||||
BfIRType origReturnType;
|
||||
deferredCallEntry->mModuleMethodInstance.mMethodInstance->GetIRFunctionInfo(this, origReturnType, origParamTypes);
|
||||
BF_ASSERT(origParamTypes.size() == deferredCallEntry->mScopeArgs.size());
|
||||
|
||||
int sretIdx = deferredCallEntry->mModuleMethodInstance.mMethodInstance->GetStructRetIdx();
|
||||
BF_ASSERT(origParamTypes.size() == deferredCallEntry->mScopeArgs.size() + ((sretIdx != -1) ? 1 : 0));
|
||||
|
||||
for (int paramIdx = 0; paramIdx < (int)deferredCallEntry->mScopeArgs.size(); paramIdx++)
|
||||
int argIdx = 0;
|
||||
int paramIdx = 0;
|
||||
for (int argIdx = 0; argIdx < (int)deferredCallEntry->mScopeArgs.size(); argIdx++, paramIdx++)
|
||||
{
|
||||
auto scopeArg = deferredCallEntry->mScopeArgs[paramIdx];
|
||||
if ((scopeArg.IsConst()) || (scopeArg.IsFake()))
|
||||
if (argIdx == sretIdx)
|
||||
paramIdx++;
|
||||
|
||||
auto scopeArg = deferredCallEntry->mScopeArgs[argIdx];
|
||||
if ((scopeArg.IsConst()) || (scopeArg.IsFake()))
|
||||
continue;
|
||||
|
||||
auto prevInsertBlock = mBfIRBuilder->GetInsertBlock();
|
||||
|
@ -92,7 +99,7 @@ bool BfModule::AddDeferredCallEntry(BfDeferredCallEntry* deferredCallEntry, BfSc
|
|||
}
|
||||
mBfIRBuilder->CreateStore(scopeArg, allocaInst);
|
||||
mBfIRBuilder->ClearDebugLocation_Last();
|
||||
deferredCallEntry->mScopeArgs[paramIdx] = allocaInst;
|
||||
deferredCallEntry->mScopeArgs[argIdx] = allocaInst;
|
||||
if (WantsLifetimes())
|
||||
scopeData->mDeferredLifetimeEnds.push_back(allocaInst);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue