@@ -4432,7 +4432,7 @@ namespace LCompilers {
4432
4432
std::map<std::string, std::map<std::string, int >>& name2memidx) {
4433
4433
get_builder0 ()
4434
4434
/* Equivalent in C++:
4435
- * while(end_point > pos) {
4435
+ * while(end_point > pos + 1 ) {
4436
4436
* tmp = pos + 1;
4437
4437
* list[pos] = list[tmp];
4438
4438
* pos = tmp;
@@ -4450,8 +4450,6 @@ namespace LCompilers {
4450
4450
// Get element to return
4451
4451
llvm::Value* item = read_item (list, LLVM::CreateLoad (*builder, pos_ptr),
4452
4452
true , *module , LLVM::is_llvm_struct (list_element_type));
4453
- // TODO: Create a macro for the following code to allocate auxiliary variables
4454
- // on stack.
4455
4453
if ( LLVM::is_llvm_struct (list_element_type) ) {
4456
4454
std::string list_element_type_code = ASRUtils::get_type_code (list_element_type);
4457
4455
LCOMPILERS_ASSERT (typecode2listtype.find (list_element_type_code) != typecode2listtype.end ());
@@ -4469,8 +4467,9 @@ namespace LCompilers {
4469
4467
// head
4470
4468
llvm_utils->start_new_block (loophead);
4471
4469
{
4472
- llvm::Value *cond = builder->CreateICmpSGT (end_point,
4473
- LLVM::CreateLoad (*builder, pos_ptr));
4470
+ llvm::Value *cond = builder->CreateICmpSGT (end_point, builder->CreateAdd (
4471
+ LLVM::CreateLoad (*builder, pos_ptr),
4472
+ llvm::ConstantInt::get (context, llvm::APInt (32 , 1 ))));
4474
4473
builder->CreateCondBr (cond, loopbody, loopend);
4475
4474
}
4476
4475
0 commit comments