]> git.lizzy.rs Git - rust.git/commitdiff
Pass small fixed-size arrays as immediates
authorBjörn Steinbrink <bsteinbr@gmail.com>
Thu, 8 Jan 2015 15:34:09 +0000 (16:34 +0100)
committerBjörn Steinbrink <bsteinbr@gmail.com>
Sun, 11 Jan 2015 00:44:03 +0000 (01:44 +0100)
Currently even small fixed-size arrays are passed as indirect
parameters, which seems to be just an oversight. Let's handle them the
same as structs of the same size, passing them as immediate values.

src/librustc_trans/trans/common.rs

index fb58d935922313443973f4a4140286f4412c20a7..f59e70d099a638342005c300f5c02ed8e3574abe 100644 (file)
@@ -244,7 +244,7 @@ pub fn type_is_immediate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) -
         return false;
     }
     match ty.sty {
-        ty::ty_struct(..) | ty::ty_enum(..) | ty::ty_tup(..) |
+        ty::ty_struct(..) | ty::ty_enum(..) | ty::ty_tup(..) | ty::ty_vec(_, Some(_)) |
         ty::ty_unboxed_closure(..) => {
             let llty = sizing_type_of(ccx, ty);
             llsize_of_alloc(ccx, llty) <= llsize_of_alloc(ccx, ccx.int_type())