mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
ensure sret is actually pointer type instead of just assuming
This commit is contained in:
parent
8bc6131b3d
commit
057e4ea57a
1 changed files with 7 additions and 4 deletions
|
@ -6460,10 +6460,13 @@ impl<'ctx> FunctionSpec<'ctx> {
|
|||
let sret_attribute_id = Attribute::get_named_enum_kind_id("sret");
|
||||
debug_assert!(sret_attribute_id > 0);
|
||||
let ret_typ = self.typ.get_param_types()[param_index as usize];
|
||||
// ret_typ is a pointer type. We need the base type here.
|
||||
let ret_base_typ = ret_typ.into_pointer_type().get_element_type();
|
||||
let sret_attribute =
|
||||
ctx.create_type_attribute(sret_attribute_id, ret_base_typ.as_any_type_enum());
|
||||
// if ret_typ is a pointer type. We need the base type here.
|
||||
let ret_base_typ = if ret_typ.is_pointer_type() {
|
||||
ret_typ.into_pointer_type().get_element_type()
|
||||
} else {
|
||||
ret_typ.as_any_type_enum()
|
||||
};
|
||||
let sret_attribute = ctx.create_type_attribute(sret_attribute_id, ret_base_typ);
|
||||
fn_val.add_attribute(AttributeLoc::Param(0), sret_attribute);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue