Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix LLVM code generation error in List comparsion #2697

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions integration_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ RUN(NAME test_list_pop LABELS cpython llvm llvm_jit NOFAST) # TODO: Remove
RUN(NAME test_list_pop2 LABELS cpython llvm llvm_jit NOFAST) # TODO: Remove NOFAST from here.
RUN(NAME test_list_pop3 LABELS cpython llvm llvm_jit)
RUN(NAME test_list_compare LABELS cpython llvm llvm_jit)
RUN(NAME test_list_compare2 LABELS cpython llvm llvm_jit)
RUN(NAME test_list_concat LABELS cpython llvm llvm_jit c NOFAST)
RUN(NAME test_list_reserve LABELS cpython llvm llvm_jit)
RUN(NAME test_const_list LABELS cpython llvm llvm_jit)
Expand Down
8 changes: 8 additions & 0 deletions integration_tests/test_list_compare2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from lpython import i32

x: list[i32] = [1, 2, 3, 4]
y: list[i32] = [5, 6, 7, 8]
z: list[i32] = [1, 2, 3, 4]

assert(x != y)
assert(x == z)
2 changes: 2 additions & 0 deletions src/libasr/codegen/llvm_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4985,6 +4985,7 @@ namespace LCompilers {
llvm::BasicBlock *mergeBB = llvm::BasicBlock::Create(context, "ifcont");
builder->CreateCondBr(cond, thenBB, elseBB);
builder->SetInsertPoint(thenBB);
builder0.SetInsertPoint(&entry_block, entry_block.getFirstInsertionPt());
llvm::AllocaInst *idx = builder0.CreateAlloca(llvm::Type::getInt32Ty(context), nullptr);
LLVM::CreateStore(*builder, llvm::ConstantInt::get(
context, llvm::APInt(32, 0)), idx);
Expand Down Expand Up @@ -5066,6 +5067,7 @@ namespace LCompilers {

llvm::Value *a_len = llvm_utils->list_api->len(l1);
llvm::Value *b_len = llvm_utils->list_api->len(l2);
builder0.SetInsertPoint(&entry_block, entry_block.getFirstInsertionPt());
llvm::AllocaInst *idx = builder0.CreateAlloca(llvm::Type::getInt32Ty(context), nullptr);
LLVM::CreateStore(*builder, llvm::ConstantInt::get(
context, llvm::APInt(32, 0)), idx);
Expand Down
Loading