Skip to content

Commit d69020c

Browse files
committed
Fix segmentation fault and use list_api
1 parent 7b21b6e commit d69020c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/libasr/codegen/llvm_utils.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2573,8 +2573,8 @@ namespace LFortran {
25732573
llvm::Module& module) {
25742574
llvm::AllocaInst *is_equal = builder->CreateAlloca(llvm::Type::getInt1Ty(context), nullptr);
25752575
LLVM::CreateStore(*builder, llvm::ConstantInt::get(context, llvm::APInt(1, 1)), is_equal);
2576-
llvm::Value *a_len = len(l1);
2577-
llvm::Value *b_len = len(l2);
2576+
llvm::Value *a_len = llvm_utils->list_api->len(l1);
2577+
llvm::Value *b_len = llvm_utils->list_api->len(l2);
25782578
llvm::Value *cond = builder->CreateICmpEQ(a_len, b_len);
25792579
llvm::Function *fn = builder->GetInsertBlock()->getParent();
25802580
llvm::BasicBlock *thenBB = llvm::BasicBlock::Create(context, "then", fn);
@@ -2591,17 +2591,17 @@ namespace LFortran {
25912591
llvm_utils->start_new_block(loophead);
25922592
{
25932593
llvm::Value* i = LLVM::CreateLoad(*builder, idx);
2594-
cond = builder->CreateICmpNE(i, a_len);
2595-
builder->CreateCondBr(cond, loopbody, loopend);
2594+
llvm::Value* cnd = builder->CreateICmpSLT(i, a_len);
2595+
builder->CreateCondBr(cnd, loopbody, loopend);
25962596
}
25972597

25982598
// body
25992599
llvm_utils->start_new_block(loopbody);
26002600
{
26012601
llvm::Value* i = LLVM::CreateLoad(*builder, idx);
2602-
llvm::Value* left_arg = read_item(l1, i,
2602+
llvm::Value* left_arg = llvm_utils->list_api->read_item(l1, i,
26032603
false, module, LLVM::is_llvm_struct(item_type));
2604-
llvm::Value* right_arg = read_item(l2, i,
2604+
llvm::Value* right_arg = llvm_utils->list_api->read_item(l2, i,
26052605
false, module, LLVM::is_llvm_struct(item_type));
26062606
llvm::Value* res = llvm_utils->is_equal_by_value(left_arg, right_arg, module,
26072607
item_type);

0 commit comments

Comments
 (0)