| 11485 | } |
| 11486 | |
| 11487 | BfIRValue BfModule::CreateFunctionFrom(BfMethodInstance* methodInstance, bool tryExisting, bool isInlined) |
| 11488 | { |
| 11489 | if (IsSkippingExtraResolveChecks()) |
| 11490 | return BfIRValue(); |
| 11491 | |
| 11492 | if (methodInstance->mMethodInstanceGroup->mOwner->IsInterface()) |
| 11493 | { |
| 11494 | //BF_ASSERT(!methodInstance->mIRFunction); |
| 11495 | return BfIRValue(); |
| 11496 | } |
| 11497 | |
| 11498 | if ((mAwaitingInitFinish) && (!mBfIRBuilder->mIgnoreWrites)) |
| 11499 | FinishInit(); |
| 11500 | |
| 11501 | auto methodDef = methodInstance->mMethodDef; |
| 11502 | StringT<4096> methodName; |
| 11503 | BfMangler::Mangle(methodName, mCompiler->GetMangleKind(), methodInstance); |
| 11504 | if (isInlined != methodInstance->mAlwaysInline) |
| 11505 | { |
| 11506 | if (isInlined) |
| 11507 | methodName += "__INLINE"; |
| 11508 | else |
| 11509 | methodName += "__NOINLINE"; |
| 11510 | } |
| 11511 | |
| 11512 | if (tryExisting) |
| 11513 | { |
| 11514 | auto func = mBfIRBuilder->GetFunction(methodName); |
| 11515 | if (func) |
| 11516 | return func; |
| 11517 | } |
| 11518 | |
| 11519 | auto intrinsic = GetIntrinsic(methodInstance); |
| 11520 | if (intrinsic) |
| 11521 | return intrinsic; |
| 11522 | |
| 11523 | if (methodInstance->GetImportCallKind() != BfImportCallKind_None) |
| 11524 | { |
| 11525 | return CreateDllImportGlobalVar(methodInstance, false); |
| 11526 | } |
| 11527 | |
| 11528 | BfIRType returnType; |
| 11529 | SizedArray<BfIRType, 8> paramTypes; |
| 11530 | methodInstance->GetIRFunctionInfo(this, returnType, paramTypes); |
| 11531 | auto funcType = mBfIRBuilder->CreateFunctionType(returnType, paramTypes, methodInstance->IsVarArgs()); |
| 11532 | |
| 11533 | auto func = mBfIRBuilder->CreateFunction(funcType, BfIRLinkageType_External, methodName); |
| 11534 | auto callingConv = GetIRCallingConvention(methodInstance); |
| 11535 | if (callingConv != BfIRCallingConv_CDecl) |
| 11536 | mBfIRBuilder->SetFuncCallingConv(func, callingConv); |
| 11537 | SetupIRMethod(methodInstance, func, isInlined); |
| 11538 | |
| 11539 | // auto srcModule = methodInstance->GetOwner()->GetModule(); |
| 11540 | // if ((srcModule != NULL) && (srcModule->mProject != mProject)) |
| 11541 | // { |
| 11542 | // if (srcModule->mProject->mTargetType == BfTargetType_BeefDynLib) |
| 11543 | // { |
| 11544 | // mBfIRBuilder->Func_AddAttribute(func, -1, BFIRAttribute_DllImport); |
nothing calls this directly
no test coverage detected