| 17523 | } |
| 17524 | |
| 17525 | BfTypedValue BfModule::TryConstCalcAppend(BfMethodInstance* methodInst, SizedArrayImpl<BfIRValue>& args, bool force) |
| 17526 | { |
| 17527 | BP_ZONE("BfModule::TryConstCalcAppend"); |
| 17528 | |
| 17529 | BF_ASSERT(methodInst->mMethodDef->mMethodType == BfMethodType_CtorCalcAppend); |
| 17530 | |
| 17531 | if ((mCompiler->mIsResolveOnly) && (!mIsComptimeModule) && (!force)) |
| 17532 | return BfTypedValue(); |
| 17533 | |
| 17534 | // We want to regenerate all ctor calls when the method internals change |
| 17535 | { |
| 17536 | auto checkTypeInst = methodInst->GetOwner(); |
| 17537 | while (checkTypeInst->mTypeDef->mHasAppendCtor) |
| 17538 | { |
| 17539 | AddDependency(checkTypeInst, mCurTypeInstance, BfDependencyMap::DependencyFlag_InlinedCall); |
| 17540 | checkTypeInst = GetBaseType(checkTypeInst); |
| 17541 | } |
| 17542 | } |
| 17543 | |
| 17544 | if (!methodInst->mMayBeConst) |
| 17545 | return BfTypedValue(); |
| 17546 | |
| 17547 | // Do we need to iterate in order to resolve mAppendAllocAlign? |
| 17548 | bool isFirstRun = methodInst->mEndingAppendAllocAlign < 0; |
| 17549 | bool wasAllConst = true; |
| 17550 | |
| 17551 | int argIdx = 0; |
| 17552 | int paramIdx = 0; |
| 17553 | while (true) |
| 17554 | { |
| 17555 | if (argIdx >= (int)args.size()) |
| 17556 | break; |
| 17557 | auto paramType = methodInst->GetParamType(paramIdx); |
| 17558 | PopulateType(paramType); |
| 17559 | int argCount = 0; |
| 17560 | if (!paramType->IsValuelessType()) |
| 17561 | { |
| 17562 | if ((!mIsComptimeModule) && (methodInst->GetParamIsSplat(paramIdx))) |
| 17563 | argCount = paramType->GetSplatCount(); |
| 17564 | else |
| 17565 | argCount = 1; |
| 17566 | |
| 17567 | for (int argOfs = 0; argOfs < argCount; argOfs++) |
| 17568 | { |
| 17569 | auto arg = args[argIdx + argOfs]; |
| 17570 | if (!arg.IsConst()) |
| 17571 | { |
| 17572 | wasAllConst = false; |
| 17573 | |
| 17574 | if (!isFirstRun) |
| 17575 | { |
| 17576 | auto& param = methodInst->mParams[argIdx]; |
| 17577 | if (param.mReferencedInConstPass) |
| 17578 | { |
| 17579 | // If this param is required as part of the const calculation then |
| 17580 | // we require that it be const... |
| 17581 | return BfTypedValue(); |
| 17582 | } |
no test coverage detected