File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -218,6 +218,14 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
218
218
llvm_utils->set_api_sc = set_api_sc.get ();
219
219
}
220
220
221
+ llvm::AllocaInst* CreateAlloca (llvm::Type* type,
222
+ llvm::Value* size=nullptr , const std::string& Name=" " ) {
223
+ llvm::BasicBlock &entry_block = builder->GetInsertBlock ()->getParent ()->getEntryBlock ();
224
+ llvm::IRBuilder<> builder0 (context);
225
+ builder0.SetInsertPoint (&entry_block, entry_block.getFirstInsertionPt ());
226
+ return builder0.CreateAlloca (type, size, Name);
227
+ }
228
+
221
229
llvm::Value* CreateLoad (llvm::Value *x) {
222
230
return LLVM::CreateLoad (*builder, x);
223
231
}
@@ -5371,7 +5379,7 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
5371
5379
this ->visit_expr_wrapper (x.m_test , true );
5372
5380
llvm::Value *cond = tmp;
5373
5381
llvm::Type* _type = llvm_utils->get_type_from_ttype_t_util (x.m_type , module .get ());
5374
- llvm::Value* ifexp_res = builder-> CreateAlloca (_type);
5382
+ llvm::Value* ifexp_res = CreateAlloca (_type);
5375
5383
llvm_utils->create_if_else (cond, [&]() {
5376
5384
this ->visit_expr_wrapper (x.m_body , true );
5377
5385
builder->CreateStore (tmp, ifexp_res);
You can’t perform that action at this time.
0 commit comments