mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Pass tag target ptr rather than alloca
This commit is contained in:
parent
a7978abdc9
commit
6c4f76c5c9
2 changed files with 23 additions and 21 deletions
|
@ -1617,15 +1617,20 @@ fn build_tag<'a, 'ctx>(
|
|||
let roc_union =
|
||||
RocUnion::tagged_from_slices(layout_interner, env.context, tags, env.target_info);
|
||||
|
||||
roc_union
|
||||
.as_struct_alloca(
|
||||
env,
|
||||
layout_interner,
|
||||
data,
|
||||
data_layout_repr,
|
||||
Some(tag_id as _),
|
||||
)
|
||||
.into()
|
||||
let tag_alloca = env
|
||||
.builder
|
||||
.build_alloca(roc_union.struct_type(), "tag_alloca");
|
||||
|
||||
roc_union.write_struct_data(
|
||||
env,
|
||||
layout_interner,
|
||||
tag_alloca,
|
||||
data,
|
||||
data_layout_repr,
|
||||
Some(tag_id as _),
|
||||
);
|
||||
|
||||
tag_alloca.into()
|
||||
}
|
||||
UnionLayout::Recursive(tags) => {
|
||||
debug_assert!(union_size > 1);
|
||||
|
@ -1746,15 +1751,13 @@ fn build_tag<'a, 'ctx>(
|
|||
let data_layout_repr = LayoutRepr::Struct(other_fields);
|
||||
let data = RocStruct::build(env, layout_interner, data_layout_repr, scope, arguments);
|
||||
|
||||
let data_struct_alloca =
|
||||
roc_union.as_struct_alloca(env, layout_interner, data, data_layout_repr, None);
|
||||
|
||||
build_memcpy(
|
||||
roc_union.write_struct_data(
|
||||
env,
|
||||
layout_interner,
|
||||
data_layout_repr,
|
||||
data_ptr,
|
||||
data_struct_alloca,
|
||||
data,
|
||||
data_layout_repr,
|
||||
None,
|
||||
);
|
||||
|
||||
data_ptr.into()
|
||||
|
|
|
@ -407,18 +407,19 @@ impl<'ctx> RocUnion<'ctx> {
|
|||
width
|
||||
}
|
||||
|
||||
pub fn as_struct_alloca<'a, 'env>(
|
||||
pub fn write_struct_data<'a, 'env>(
|
||||
&self,
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
layout_interner: &STLayoutInterner<'a>,
|
||||
// The allocation of the tag to write into.
|
||||
tag_alloca: PointerValue<'ctx>,
|
||||
// The data to write into the union.
|
||||
data: RocStruct<'ctx>,
|
||||
data_layout: LayoutRepr<'a>,
|
||||
tag_id: Option<usize>,
|
||||
) -> PointerValue<'ctx> {
|
||||
) {
|
||||
debug_assert_eq!(tag_id.is_some(), self.tag_type.is_some());
|
||||
|
||||
let tag_alloca = env.builder.build_alloca(self.struct_type(), "tag_alloca");
|
||||
|
||||
let data_buffer = env
|
||||
.builder
|
||||
.new_build_struct_gep(
|
||||
|
@ -482,8 +483,6 @@ impl<'ctx> RocUnion<'ctx> {
|
|||
|
||||
env.builder.build_store(tag_id_ptr, tag_id);
|
||||
}
|
||||
|
||||
tag_alloca
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue