layout add allocation_alignment_bytes

This commit is contained in:
Folkert 2021-09-03 23:56:42 +02:00
parent 63c488acd8
commit 97577c92cf
2 changed files with 71 additions and 2 deletions

View file

@ -158,12 +158,14 @@ impl<'ctx> PointerToRefcount<'ctx> {
}
pub fn decrement<'a, 'env>(&self, env: &Env<'a, 'ctx, 'env>, layout: &Layout<'a>) {
let alignment = layout
.allocation_alignment_bytes(env.ptr_bytes)
.max(env.ptr_bytes);
let context = env.context;
let block = env.builder.get_insert_block().expect("to be in a function");
let di_location = env.builder.get_current_debug_location().unwrap();
let alignment = layout.alignment_bytes(env.ptr_bytes).max(env.ptr_bytes);
let fn_name = &format!("decrement_refcounted_ptr_{}", alignment);
let function = match env.module.get_function(fn_name) {
@ -1142,6 +1144,10 @@ fn build_rec_union_help<'a, 'ctx, 'env>(
env.builder.position_at_end(should_recurse_block);
// to increment/decrement the cons-cell itself
let refcount_ptr = PointerToRefcount::from_ptr_to_data(env, value_ptr);
let call_mode = mode_to_call_mode(fn_val, mode);
let layout = Layout::Union(union_layout);
match mode {