Merge commit '482e8540a1b757ed7bccc2041c5400f051fdb01e' into subtree-update_cg_gcc_2025-08-04
This commit is contained in:
@@ -540,9 +540,15 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
|
||||
|
||||
fn ret(&mut self, mut value: RValue<'gcc>) {
|
||||
let expected_return_type = self.current_func().get_return_type();
|
||||
if !expected_return_type.is_compatible_with(value.get_type()) {
|
||||
// NOTE: due to opaque pointers now being used, we need to cast here.
|
||||
value = self.context.new_cast(self.location, value, expected_return_type);
|
||||
let value_type = value.get_type();
|
||||
if !expected_return_type.is_compatible_with(value_type) {
|
||||
// NOTE: due to opaque pointers now being used, we need to (bit)cast here.
|
||||
if self.is_native_int_type(value_type) && self.is_native_int_type(expected_return_type)
|
||||
{
|
||||
value = self.context.new_cast(self.location, value, expected_return_type);
|
||||
} else {
|
||||
value = self.context.new_bitcast(self.location, value, expected_return_type);
|
||||
}
|
||||
}
|
||||
self.llbb().end_with_return(self.location, value);
|
||||
}
|
||||
@@ -1279,11 +1285,19 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
|
||||
|
||||
fn intcast(
|
||||
&mut self,
|
||||
value: RValue<'gcc>,
|
||||
mut value: RValue<'gcc>,
|
||||
dest_typ: Type<'gcc>,
|
||||
_is_signed: bool,
|
||||
is_signed: bool,
|
||||
) -> RValue<'gcc> {
|
||||
// NOTE: is_signed is for value, not dest_typ.
|
||||
let value_type = value.get_type();
|
||||
if is_signed && !value_type.is_signed(self.cx) {
|
||||
let signed_type = value_type.to_signed(self.cx);
|
||||
value = self.gcc_int_cast(value, signed_type);
|
||||
} else if !is_signed && value_type.is_signed(self.cx) {
|
||||
let unsigned_type = value_type.to_unsigned(self.cx);
|
||||
value = self.gcc_int_cast(value, unsigned_type);
|
||||
}
|
||||
|
||||
self.gcc_int_cast(value, dest_typ)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user