@@ -303,6 +303,8 @@ llvm::Value* RowFuncBuilder::codegenOutputSlot(
303303 }
304304 const auto key_slot_idx = get_heap_key_slot_index (
305305 ra_exe_unit_.target_exprs , target_idx, config_.exec .group_by .bigint_count );
306+ CHECK_LE (query_mem_desc.getColOffInBytes (key_slot_idx),
307+ std::numeric_limits<uint32_t >::max ());
306308 return emitCall (
307309 fname,
308310 {groups_buffer,
@@ -881,7 +883,7 @@ llvm::Value* RowFuncBuilder::codegenAggColumnPtr(
881883 chosen_bytes == 8 );
882884 CHECK (output_buffer_byte_stream);
883885 CHECK (out_row_idx);
884- uint32_t col_off = query_mem_desc.getColOffInBytes (agg_out_off);
886+ size_t col_off = query_mem_desc.getColOffInBytes (agg_out_off);
885887 // multiplying by chosen_bytes, i.e., << log2(chosen_bytes)
886888#ifdef _WIN32
887889 auto out_per_col_byte_idx =
@@ -890,8 +892,7 @@ llvm::Value* RowFuncBuilder::codegenAggColumnPtr(
890892 auto out_per_col_byte_idx =
891893 LL_BUILDER.CreateShl (out_row_idx, __builtin_ffs (chosen_bytes) - 1 );
892894#endif
893- auto byte_offset = LL_BUILDER.CreateAdd (out_per_col_byte_idx,
894- LL_INT (static_cast <int64_t >(col_off)));
895+ auto byte_offset = LL_BUILDER.CreateAdd (out_per_col_byte_idx, LL_INT (col_off));
895896 byte_offset->setName (" out_byte_off_target_" + std::to_string (target_idx));
896897 auto output_ptr = LL_BUILDER.CreateGEP (
897898 output_buffer_byte_stream->getType ()->getScalarType ()->getPointerElementType (),
@@ -903,11 +904,15 @@ llvm::Value* RowFuncBuilder::codegenAggColumnPtr(
903904 output_ptr->getType ()->getPointerAddressSpace ()));
904905 agg_col_ptr->setName (" out_ptr_target_" + std::to_string (target_idx));
905906 } else {
906- uint32_t col_off = query_mem_desc.getColOffInBytes (agg_out_off);
907+ size_t col_off = query_mem_desc.getColOffInBytes (agg_out_off);
907908 CHECK_EQ (size_t (0 ), col_off % chosen_bytes);
908909 col_off /= chosen_bytes;
909- CHECK (std::get<1 >(agg_out_ptr_w_idx));
910- auto offset = LL_BUILDER.CreateAdd (std::get<1 >(agg_out_ptr_w_idx), LL_INT (col_off));
910+ auto agg_out_idx = std::get<1 >(agg_out_ptr_w_idx);
911+ CHECK (agg_out_idx);
912+ if (!agg_out_idx->getType ()->isIntegerTy (64 )) {
913+ agg_out_idx = executor_->cgen_state_ ->castToTypeIn (agg_out_idx, 64 );
914+ }
915+ auto offset = LL_BUILDER.CreateAdd (agg_out_idx, LL_INT (col_off));
911916 auto * bit_cast = LL_BUILDER.CreateBitCast (
912917 std::get<0 >(agg_out_ptr_w_idx),
913918 llvm::PointerType::get (
@@ -919,7 +924,7 @@ llvm::Value* RowFuncBuilder::codegenAggColumnPtr(
919924 offset);
920925 }
921926 } else {
922- uint32_t col_off = query_mem_desc.getColOnlyOffInBytes (agg_out_off);
927+ size_t col_off = query_mem_desc.getColOnlyOffInBytes (agg_out_off);
923928 CHECK_EQ (size_t (0 ), col_off % chosen_bytes);
924929 col_off /= chosen_bytes;
925930 auto * bit_cast = LL_BUILDER.CreateBitCast (
0 commit comments