mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 14:24:45 +00:00
Have RocUnion::as_struct_value return an alloca instead
Saves a useless store/load.
This commit is contained in:
parent
0403509f64
commit
465cee053e
2 changed files with 14 additions and 24 deletions
|
@ -3,7 +3,7 @@ use crate::llvm::memcpy::build_memcpy;
|
|||
use bumpalo::collections::Vec as AVec;
|
||||
use inkwell::context::Context;
|
||||
use inkwell::types::{BasicType, BasicTypeEnum, FloatType, IntType, StructType};
|
||||
use inkwell::values::StructValue;
|
||||
use inkwell::values::PointerValue;
|
||||
use inkwell::AddressSpace;
|
||||
use roc_builtins::bitcode::{FloatWidth, IntWidth};
|
||||
use roc_mono::layout::{
|
||||
|
@ -407,14 +407,14 @@ impl<'ctx> RocUnion<'ctx> {
|
|||
width
|
||||
}
|
||||
|
||||
pub fn as_struct_value<'a, 'env>(
|
||||
pub fn as_struct_alloca<'a, 'env>(
|
||||
&self,
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
layout_interner: &STLayoutInterner<'a>,
|
||||
data: RocStruct<'ctx>,
|
||||
data_layout: LayoutRepr<'a>,
|
||||
tag_id: Option<usize>,
|
||||
) -> StructValue<'ctx> {
|
||||
) -> 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");
|
||||
|
@ -483,9 +483,7 @@ impl<'ctx> RocUnion<'ctx> {
|
|||
env.builder.build_store(tag_id_ptr, tag_id);
|
||||
}
|
||||
|
||||
env.builder
|
||||
.new_build_load(self.struct_type(), tag_alloca, "load_tag")
|
||||
.into_struct_value()
|
||||
tag_alloca
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue