MCPcopy Create free account
hub / github.com/beefytech/Beef / AllocLocalVariable

Method AllocLocalVariable

IDEHelper/Compiler/BfModule.cpp:16088–16115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16086//////////////////////////////////////////////////////////////////////////
16087
16088BfIRValue 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
16117BfTypedValue BfModule::CreateOutVariable(BfAstNode* refNode, BfVariableDeclaration* variableDeclaration, BfAstNode* paramNameNode, BfType* variableType, BfTypedValue initValue)
16118{

Callers

nothing calls this directly

Calls 9

GetFakeValMethod · 0.80
CreateLifetimeStartMethod · 0.80
ClearDebugLocationMethod · 0.80
IsValuelessTypeMethod · 0.45
c_strMethod · 0.45
ApplyMethod · 0.45
GetInsertBlockMethod · 0.45
SetInsertPointMethod · 0.45
CreateAlignedStoreMethod · 0.45

Tested by

no test coverage detected