| 2081 | } |
| 2082 | |
| 2083 | BfIRValue BfModule::CreateAlloca(BfIRType irType, int align, bool addLifetime, const char* name, BfIRValue arraySize) |
| 2084 | { |
| 2085 | if (mBfIRBuilder->mIgnoreWrites) |
| 2086 | return mBfIRBuilder->GetFakeVal(); |
| 2087 | |
| 2088 | BF_ASSERT((*(int8*)&addLifetime == 1) || (*(int8*)&addLifetime == 0)); |
| 2089 | auto prevInsertBlock = mBfIRBuilder->GetInsertBlock(); |
| 2090 | if (!mBfIRBuilder->mIgnoreWrites) |
| 2091 | BF_ASSERT(!prevInsertBlock.IsFake()); |
| 2092 | mBfIRBuilder->SetInsertPoint(mCurMethodState->mIRHeadBlock); |
| 2093 | BfIRValue allocaInst; |
| 2094 | if (arraySize) |
| 2095 | allocaInst = mBfIRBuilder->CreateAlloca(irType, arraySize); |
| 2096 | else |
| 2097 | allocaInst = mBfIRBuilder->CreateAlloca(irType); |
| 2098 | if (align > 0) |
| 2099 | mBfIRBuilder->SetAllocaAlignment(allocaInst, align); |
| 2100 | mBfIRBuilder->ClearDebugLocation(allocaInst); |
| 2101 | if (name != NULL) |
| 2102 | mBfIRBuilder->SetName(allocaInst, name); |
| 2103 | mBfIRBuilder->SetInsertPoint(prevInsertBlock); |
| 2104 | if ((addLifetime) && (WantsLifetimes())) |
| 2105 | { |
| 2106 | auto lifetimeStart = mBfIRBuilder->CreateLifetimeStart(allocaInst); |
| 2107 | mBfIRBuilder->ClearDebugLocation(lifetimeStart); |
| 2108 | mCurMethodState->mCurScope->mDeferredLifetimeEnds.push_back(allocaInst); |
| 2109 | } |
| 2110 | return allocaInst; |
| 2111 | } |
| 2112 | |
| 2113 | BfIRValue BfModule::CreateAlloca(BfType* type, bool addLifetime, const char* name, BfIRValue arraySize) |
| 2114 | { |
no test coverage detected