llvm::Value *Sorter::GetNumberOfStoredTuples(CodeGen &codegen, llvm::Value *sorter_ptr) const { // TODO: util::Sorter has a function to handle this ... llvm::Value *start_pos = GetStartPosition(codegen, sorter_ptr); llvm::Value *end_pos = GetEndPosition(codegen, sorter_ptr); llvm::Value *tuple_size = codegen->CreateZExt(GetTupleSize(codegen), codegen.Int64Type()); llvm::Value *diff_bytes = codegen->CreatePtrDiff(end_pos, start_pos); llvm::Value *num_tuples = codegen->CreateUDiv(diff_bytes, tuple_size); return codegen->CreateTruncOrBitCast(num_tuples, codegen.Int32Type()); }