@@ -15,25 +15,29 @@ use super::common::*;
15
15
use super :: machine:: * ;
16
16
17
17
pub 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) ;
34
38
}
35
39
} else {
36
- fty. ret . make_indirect ( ccx ) ;
40
+ fty. ret . extend_integer_width_to ( 32 ) ;
37
41
}
38
42
}
39
43
@@ -42,6 +46,8 @@ pub fn compute_abi_info(ccx: &CrateContext, fty: &mut FnType) {
42
46
if arg. ty . kind ( ) == Struct {
43
47
arg. make_indirect ( ccx) ;
44
48
arg. attrs . set ( Attribute :: ByVal ) ;
49
+ } else {
50
+ arg. extend_integer_width_to ( 32 ) ;
45
51
}
46
52
}
47
53
}
0 commit comments