Skip to content

Commit 666a58d

Browse files
hankluo6ubaidsk
authored andcommitted
Adjust insert point for correct alloca positioning
1 parent 5452ed1 commit 666a58d

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

src/libasr/codegen/llvm_utils.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4985,6 +4985,7 @@ namespace LCompilers {
49854985
llvm::BasicBlock *mergeBB = llvm::BasicBlock::Create(context, "ifcont");
49864986
builder->CreateCondBr(cond, thenBB, elseBB);
49874987
builder->SetInsertPoint(thenBB);
4988+
builder0.SetInsertPoint(&entry_block, entry_block.getFirstInsertionPt());
49884989
llvm::AllocaInst *idx = builder0.CreateAlloca(llvm::Type::getInt32Ty(context), nullptr);
49894990
LLVM::CreateStore(*builder, llvm::ConstantInt::get(
49904991
context, llvm::APInt(32, 0)), idx);
@@ -5066,6 +5067,7 @@ namespace LCompilers {
50665067

50675068
llvm::Value *a_len = llvm_utils->list_api->len(l1);
50685069
llvm::Value *b_len = llvm_utils->list_api->len(l2);
5070+
builder0.SetInsertPoint(&entry_block, entry_block.getFirstInsertionPt());
50695071
llvm::AllocaInst *idx = builder0.CreateAlloca(llvm::Type::getInt32Ty(context), nullptr);
50705072
LLVM::CreateStore(*builder, llvm::ConstantInt::get(
50715073
context, llvm::APInt(32, 0)), idx);

0 commit comments

Comments
 (0)