correct sret to use the element type and not the pointer type

This commit is contained in:
Brendan Hansknecht 2022-07-18 22:04:34 -07:00
parent b190b09b78
commit 9c35d29c24
No known key found for this signature in database
GPG Key ID: A2E3B0B6E483038E

View File

@ -6411,8 +6411,10 @@ 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_typ.as_any_type_enum());
ctx.create_type_attribute(sret_attribute_id, ret_base_typ.as_any_type_enum());
fn_val.add_attribute(AttributeLoc::Param(0), sret_attribute);
}
}