mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
fix all the things
This commit is contained in:
parent
99d0d9c732
commit
16f6259f7f
23 changed files with 81 additions and 149 deletions
|
@ -1,5 +1,5 @@
|
|||
use crate::llvm::build::Env;
|
||||
use crate::llvm::build::{cast_block_of_memory_to_tag, FAST_CALL_CONV};
|
||||
use crate::llvm::build::{cast_block_of_memory_to_tag, get_tag_id, FAST_CALL_CONV};
|
||||
use crate::llvm::build_list::{list_len, load_list_ptr};
|
||||
use crate::llvm::build_str::str_equal;
|
||||
use crate::llvm::convert::basic_type_from_layout;
|
||||
|
@ -846,10 +846,8 @@ fn build_tag_eq_help<'a, 'ctx, 'env>(
|
|||
|
||||
match union_layout {
|
||||
NonRecursive(tags) => {
|
||||
let id1 =
|
||||
crate::llvm::build::get_tag_id(env, parent, union_layout, tag1).into_int_value();
|
||||
let id2 =
|
||||
crate::llvm::build::get_tag_id(env, parent, union_layout, tag2).into_int_value();
|
||||
let id1 = get_tag_id(env, parent, union_layout, tag1).into_int_value();
|
||||
let id2 = get_tag_id(env, parent, union_layout, tag2).into_int_value();
|
||||
|
||||
let compare_tag_fields = ctx.append_basic_block(parent, "compare_tag_fields");
|
||||
|
||||
|
@ -927,9 +925,8 @@ fn build_tag_eq_help<'a, 'ctx, 'env>(
|
|||
|
||||
env.builder.position_at_end(compare_tag_ids);
|
||||
|
||||
// SAFETY we know that non-recursive tags cannot be NULL
|
||||
let id1 = unsafe { rec_tag_id_unsafe(env, tag1.into_pointer_value()) };
|
||||
let id2 = unsafe { rec_tag_id_unsafe(env, tag2.into_pointer_value()) };
|
||||
let id1 = get_tag_id(env, parent, union_layout, tag1).into_int_value();
|
||||
let id2 = get_tag_id(env, parent, union_layout, tag2).into_int_value();
|
||||
|
||||
let compare_tag_fields = ctx.append_basic_block(parent, "compare_tag_fields");
|
||||
|
||||
|
@ -974,9 +971,6 @@ fn build_tag_eq_help<'a, 'ctx, 'env>(
|
|||
env.builder.build_switch(id1, default, &cases);
|
||||
}
|
||||
NullableUnwrapped { other_fields, .. } => {
|
||||
// drop the tag id; it is not stored
|
||||
let other_fields = &other_fields[1..];
|
||||
|
||||
let ptr_equal = env.builder.build_int_compare(
|
||||
IntPredicate::EQ,
|
||||
env.builder
|
||||
|
@ -1082,9 +1076,8 @@ fn build_tag_eq_help<'a, 'ctx, 'env>(
|
|||
|
||||
env.builder.position_at_end(compare_other);
|
||||
|
||||
// SAFETY we know at this point that tag1/tag2 are not NULL
|
||||
let id1 = unsafe { rec_tag_id_unsafe(env, tag1.into_pointer_value()) };
|
||||
let id2 = unsafe { rec_tag_id_unsafe(env, tag2.into_pointer_value()) };
|
||||
let id1 = get_tag_id(env, parent, union_layout, tag1).into_int_value();
|
||||
let id2 = get_tag_id(env, parent, union_layout, tag2).into_int_value();
|
||||
|
||||
let compare_tag_fields = ctx.append_basic_block(parent, "compare_tag_fields");
|
||||
|
||||
|
@ -1212,19 +1205,3 @@ fn eq_ptr_to_struct<'a, 'ctx, 'env>(
|
|||
)
|
||||
.into_int_value()
|
||||
}
|
||||
|
||||
unsafe fn rec_tag_id_unsafe<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
tag: PointerValue<'ctx>,
|
||||
) -> IntValue<'ctx> {
|
||||
let ptr = env
|
||||
.builder
|
||||
.build_bitcast(
|
||||
tag,
|
||||
env.context.i64_type().ptr_type(AddressSpace::Generic),
|
||||
"cast_for_tag_id",
|
||||
)
|
||||
.into_pointer_value();
|
||||
|
||||
env.builder.build_load(ptr, "load_tag_id").into_int_value()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue