Avoid pointless allocas for "nil" return values
By using "void" instead of "{}" as the LLVM type for nil, we can avoid
the alloca/store/load sequence for the return value, resulting in less
and simpler IR code.
This reduces compile times by about 10%.
diff --git a/src/librustc/middle/trans/cabi.rs b/src/librustc/middle/trans/cabi.rs
index acc3293..3739805 100644
--- a/src/librustc/middle/trans/cabi.rs
+++ b/src/librustc/middle/trans/cabi.rs
@@ -179,16 +179,18 @@
}
}
- let llretval = load_inbounds(bcx, llargbundle, [ 0, arg_tys.len() ]);
- let llretval = if self.ret_ty.cast {
- let retptr = BitCast(bcx, llretval, T_ptr(self.ret_ty.ty));
- Load(bcx, retptr)
- } else {
- Load(bcx, llretval)
- };
- let llretptr = BitCast(bcx,
- bcx.fcx.llretptr.get(),
- T_ptr(self.ret_ty.ty));
- Store(bcx, llretval, llretptr);
+ if bcx.fcx.llretptr.is_some() {
+ let llretval = load_inbounds(bcx, llargbundle, [ 0, arg_tys.len() ]);
+ let llretval = if self.ret_ty.cast {
+ let retptr = BitCast(bcx, llretval, T_ptr(self.ret_ty.ty));
+ Load(bcx, retptr)
+ } else {
+ Load(bcx, llretval)
+ };
+ let llretptr = BitCast(bcx,
+ bcx.fcx.llretptr.get(),
+ T_ptr(self.ret_ty.ty));
+ Store(bcx, llretval, llretptr);
+ }
}
}