diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index 87d76dbe..f75e00f7 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/IDEHelper/Compiler/BfModule.cpp @@ -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; diff --git a/IDEHelper/Compiler/BfStmtEvaluator.cpp b/IDEHelper/Compiler/BfStmtEvaluator.cpp index 283b2861..e08b636c 100644 --- a/IDEHelper/Compiler/BfStmtEvaluator.cpp +++ b/IDEHelper/Compiler/BfStmtEvaluator.cpp @@ -72,12 +72,19 @@ bool BfModule::AddDeferredCallEntry(BfDeferredCallEntry* deferredCallEntry, BfSc SizedArray 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); }