Skip to content

Commit 21e27d8

Browse files
authored
Merge pull request #2697 from hankluo6/list_comp
Fix LLVM code generation error in List comparsion
2 parents 5452ed1 + f3857e7 commit 21e27d8

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

integration_tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,7 @@ RUN(NAME test_list_pop LABELS cpython llvm llvm_jit NOFAST) # TODO: Remove
555555
RUN(NAME test_list_pop2 LABELS cpython llvm llvm_jit NOFAST) # TODO: Remove NOFAST from here.
556556
RUN(NAME test_list_pop3 LABELS cpython llvm llvm_jit)
557557
RUN(NAME test_list_compare LABELS cpython llvm llvm_jit)
558+
RUN(NAME test_list_compare2 LABELS cpython llvm llvm_jit)
558559
RUN(NAME test_list_concat LABELS cpython llvm llvm_jit c NOFAST)
559560
RUN(NAME test_list_reserve LABELS cpython llvm llvm_jit)
560561
RUN(NAME test_const_list LABELS cpython llvm llvm_jit)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from lpython import i32
2+
3+
x: list[i32] = [1, 2, 3, 4]
4+
y: list[i32] = [5, 6, 7, 8]
5+
z: list[i32] = [1, 2, 3, 4]
6+
7+
assert(x != y)
8+
assert(x == z)

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)