@@ -83,12 +83,10 @@ where
8383 return ;
8484 }
8585 if !ret. layout . is_aggregate ( ) {
86- if kind == AbiKind :: DarwinPCS {
87- // On Darwin, when returning an i8/i16, it must be sign-extended to 32 bits,
88- // and likewise a u8/u16 must be zero-extended to 32-bits.
89- // See also: <https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms#Pass-Arguments-to-Functions-Correctly>
90- ret. extend_integer_width_to ( 32 )
91- }
86+ // Even if AAPCS does not demand sign extension of smaller-than-32-bit integer returns,
87+ // Darwin requires it: <https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms#Pass-Arguments-to-Functions-Correctly>
88+ // It is harmless to do so in every case. If you ask for only 16 bits, don't inspect the other 48!
89+ ret. extend_integer_width_to ( 32 ) ;
9290 softfloat_float_abi ( cx. target_spec ( ) , ret) ;
9391 return ;
9492 }
@@ -115,14 +113,11 @@ where
115113 return ;
116114 }
117115 if !arg. layout . is_aggregate ( ) {
118- if kind == AbiKind :: DarwinPCS {
119- // On Darwin, when passing an i8/i16, it must be sign-extended to 32 bits,
120- // and likewise a u8/u16 must be zero-extended to 32-bits.
121- // See also: <https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms#Pass-Arguments-to-Functions-Correctly>
122- arg. extend_integer_width_to ( 32 ) ;
123- }
116+ // Even if AAPCS does not demand sign extension of smaller-than-32-bit integer arguments,
117+ // Darwin requires it: <https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms#Pass-Arguments-to-Functions-Correctly>
118+ // It is harmless to do so in every case. If you ask for only 16 bits, don't inspect the other 48!
119+ arg. extend_integer_width_to ( 32 ) ;
124120 softfloat_float_abi ( cx. target_spec ( ) , arg) ;
125-
126121 return ;
127122 }
128123 if let Some ( uniform) = is_homogeneous_aggregate ( cx, arg) {
0 commit comments