| 16086 | ////////////////////////////////////////////////////////////////////////// |
| 16087 | |
| 16088 | BfIRValue BfModule::AllocLocalVariable(BfType* type, const StringImpl& name, bool doLifetimeEnd) |
| 16089 | { |
| 16090 | //if ((type->IsValuelessType()) || (type->IsMethodRef())) |
| 16091 | if (type->IsValuelessType()) |
| 16092 | return mBfIRBuilder->GetFakeVal(); |
| 16093 | |
| 16094 | auto allocaInst = CreateAlloca(type, doLifetimeEnd, name.c_str()); |
| 16095 | if ((!doLifetimeEnd) && (WantsLifetimes())) |
| 16096 | { |
| 16097 | auto lifetimeStart = mBfIRBuilder->CreateLifetimeStart(allocaInst); |
| 16098 | mBfIRBuilder->ClearDebugLocation(lifetimeStart); |
| 16099 | } |
| 16100 | |
| 16101 | bool initLocalVariables = mCompiler->mOptions.mInitLocalVariables; |
| 16102 | auto typeOptions = GetTypeOptions(); |
| 16103 | if (typeOptions != NULL) |
| 16104 | initLocalVariables = typeOptions->Apply(initLocalVariables, BfOptionFlags_InitLocalVariables); |
| 16105 | // Local variable inits are implicitly handled in the Beef Backend |
| 16106 | if ((initLocalVariables) && (!IsTargetingBeefBackend())) |
| 16107 | { |
| 16108 | auto prevBlock = mBfIRBuilder->GetInsertBlock(); |
| 16109 | mBfIRBuilder->SetInsertPoint(mCurMethodState->mIRInitBlock); |
| 16110 | auto storeInst = mBfIRBuilder->CreateAlignedStore(GetDefaultValue(type), allocaInst, type->mAlign); |
| 16111 | mBfIRBuilder->ClearDebugLocation(storeInst); |
| 16112 | mBfIRBuilder->SetInsertPoint(prevBlock); |
| 16113 | } |
| 16114 | return allocaInst; |
| 16115 | } |
| 16116 | |
| 16117 | BfTypedValue BfModule::CreateOutVariable(BfAstNode* refNode, BfVariableDeclaration* variableDeclaration, BfAstNode* paramNameNode, BfType* variableType, BfTypedValue initValue) |
| 16118 | { |
nothing calls this directly
no test coverage detected