@@ -15,25 +15,29 @@ use super::common::*;
1515use super :: machine:: * ;
1616
1717pub fn compute_abi_info ( ccx : & CrateContext , fty : & mut FnType ) {
18- if !fty. ret . is_ignore ( ) && fty. ret . ty . kind ( ) == Struct {
19- // Returning a structure. Most often, this will use
20- // a hidden first argument. On some platforms, though,
21- // small structs are returned as integers.
22- //
23- // Some links:
24- // http://www.angelcode.com/dev/callconv/callconv.html
25- // Clang's ABI handling is in lib/CodeGen/TargetInfo.cpp
26- let t = & ccx. sess ( ) . target . target ;
27- if t. options . is_like_osx || t. options . is_like_windows {
28- match llsize_of_alloc ( ccx, fty. ret . ty ) {
29- 1 => fty. ret . cast = Some ( Type :: i8 ( ccx) ) ,
30- 2 => fty. ret . cast = Some ( Type :: i16 ( ccx) ) ,
31- 4 => fty. ret . cast = Some ( Type :: i32 ( ccx) ) ,
32- 8 => fty. ret . cast = Some ( Type :: i64 ( ccx) ) ,
33- _ => fty. ret . make_indirect ( ccx)
18+ if !fty. ret . is_ignore ( ) {
19+ if fty. ret . ty . kind ( ) == Struct {
20+ // Returning a structure. Most often, this will use
21+ // a hidden first argument. On some platforms, though,
22+ // small structs are returned as integers.
23+ //
24+ // Some links:
25+ // http://www.angelcode.com/dev/callconv/callconv.html
26+ // Clang's ABI handling is in lib/CodeGen/TargetInfo.cpp
27+ let t = & ccx. sess ( ) . target . target ;
28+ if t. options . is_like_osx || t. options . is_like_windows {
29+ match llsize_of_alloc ( ccx, fty. ret . ty ) {
30+ 1 => fty. ret . cast = Some ( Type :: i8 ( ccx) ) ,
31+ 2 => fty. ret . cast = Some ( Type :: i16 ( ccx) ) ,
32+ 4 => fty. ret . cast = Some ( Type :: i32 ( ccx) ) ,
33+ 8 => fty. ret . cast = Some ( Type :: i64 ( ccx) ) ,
34+ _ => fty. ret . make_indirect ( ccx)
35+ }
36+ } else {
37+ fty. ret . make_indirect ( ccx) ;
3438 }
3539 } else {
36- fty. ret . make_indirect ( ccx ) ;
40+ fty. ret . extend_integer_width_to ( 32 ) ;
3741 }
3842 }
3943
@@ -42,6 +46,8 @@ pub fn compute_abi_info(ccx: &CrateContext, fty: &mut FnType) {
4246 if arg. ty . kind ( ) == Struct {
4347 arg. make_indirect ( ccx) ;
4448 arg. attrs . set ( Attribute :: ByVal ) ;
49+ } else {
50+ arg. extend_integer_width_to ( 32 ) ;
4551 }
4652 }
4753}
0 commit comments