]> git.lizzy.rs Git - rust.git/commitdiff
fast path for zsts
authorOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Mon, 13 Feb 2017 12:46:39 +0000 (13:46 +0100)
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Tue, 14 Feb 2017 09:19:18 +0000 (10:19 +0100)
src/eval_context.rs
src/terminator/mod.rs

index 2dd6662e63086e3defa5fda7b3d7a7428634a661..9fb6492efd39e460e3d2679fac808ac1e770eae8 100644 (file)
@@ -436,6 +436,9 @@ pub(super) fn eval_rvalue_into_lvalue(
                 self.write_primval(dest, operator::unary_op(un_op, val, kind)?, dest_ty)?;
             }
 
+            // Skip everything for zsts
+            Aggregate(..) if self.type_size(dest_ty)? == Some(0) => {}
+
             Aggregate(ref kind, ref operands) => {
                 self.inc_step_counter_and_check_limit(operands.len() as u64)?;
                 use rustc::ty::layout::Layout::*;
index a3b47f533f4be37aa294185ece4c45c5fa017485..d8035c9f6700fac551d7d7718cd13417dd122044 100644 (file)
@@ -501,13 +501,20 @@ pub(crate) fn unpack_fn_args(&self, args: &mut Vec<(Value, Ty<'tcx>)>) -> EvalRe
                 (&ty::TyTuple(fields, _),
                  &Layout::Univariant { ref variant, .. }) => {
                     let offsets = variant.offsets.iter().map(|s| s.bytes());
-                    let last_ptr = match last {
-                        Value::ByRef(ptr) => ptr,
-                        _ => bug!("rust-call ABI tuple argument wasn't Value::ByRef"),
-                    };
-                    for (offset, ty) in offsets.zip(fields) {
-                        let arg = Value::ByRef(last_ptr.offset(offset));
-                        args.push((arg, ty));
+                    match last {
+                        Value::ByRef(last_ptr) => {
+                            for (offset, ty) in offsets.zip(fields) {
+                                let arg = Value::ByRef(last_ptr.offset(offset));
+                                args.push((arg, ty));
+                            }
+                        },
+                        // propagate undefs
+                        undef @ Value::ByVal(PrimVal::Undef) => {
+                            for field_ty in fields {
+                                args.push((undef, field_ty));
+                            }
+                        },
+                        _ => bug!("rust-call ABI tuple argument was {:?}", last),
                     }
                 }
                 ty => bug!("expected tuple as last argument in function with 'rust-call' ABI, got {:?}", ty),