From 273c2c9dfae9ba06627203160bb7ec4d2341ed59 Mon Sep 17 00:00:00 2001 From: Guilherme Leobas Date: Fri, 12 May 2023 12:34:05 -0300 Subject: [PATCH] Replace "builder.alloca" by "allocate_varlen_buffer" --- rbc/heavydb/buffer.py | 6 +++++- rbc/heavydb/text_encoding_none.py | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/rbc/heavydb/buffer.py b/rbc/heavydb/buffer.py index ac3f1fdc..0e3e6e81 100644 --- a/rbc/heavydb/buffer.py +++ b/rbc/heavydb/buffer.py @@ -32,6 +32,7 @@ from rbc import typesystem from rbc.targetinfo import TargetInfo +from .allocator import allocate_varlen_buffer from .metatype import HeavyDBMetaType int8_t = ir.IntType(8) @@ -209,7 +210,10 @@ def heavydb_buffer_constructor(context, builder, sig, args): ptr = memalloc(context, builder, ptr_type, element_count, element_size) llty = context.get_value_type(sig.return_type.dtype) - st_ptr = builder.alloca(llty) + st_size = context.get_abi_sizeof(llty) + st_ptr = builder.bitcast(allocate_varlen_buffer(builder, int64_t(st_size), + int64_t(1)), + llty.as_pointer()) zero, one, two = int32_t(0), int32_t(1), int32_t(2) builder.store(ptr, builder.gep(st_ptr, [zero, zero])) diff --git a/rbc/heavydb/text_encoding_none.py b/rbc/heavydb/text_encoding_none.py index b760261c..e60305e6 100644 --- a/rbc/heavydb/text_encoding_none.py +++ b/rbc/heavydb/text_encoding_none.py @@ -15,9 +15,9 @@ from rbc import typesystem +from .allocator import allocate_varlen_buffer from .array import ArrayPointer from .buffer import Buffer, HeavyDBBufferType, heavydb_buffer_constructor -from .allocator import allocate_varlen_buffer i8 = ir.IntType(8) i8p = i8.as_pointer() @@ -176,7 +176,10 @@ def text_encoding_none_unicode_ctor(context, builder, sig, args): uni_str = context.make_helper(builder, sig.args[0], value=args[0]) llty = context.get_value_type(sig.return_type.dtype) - st_ptr = builder.alloca(llty) + st_size = context.get_abi_sizeof(llty) + st_ptr = builder.bitcast(allocate_varlen_buffer(builder, int64_t(st_size), + int64_t(1)), + llty.as_pointer()) zero, one, two = i32(0), i32(1), i32(2) eq = builder.icmp_signed('==', uni_str.length, uni_str.length.type(0))